2010-07-24 121 views
-2

我创建usercontrol 当我将它添加到我的wpf窗口获取此错误: 错误47标记'UserControl1'不存在于XML名称空间'clr-namespace:WPFTestApp;程序集= WPFTestApp'中。线115位置14Wpf用户控制错误


<Grid.Background> 
     <ImageBrush ImageSource="background.jpg" TileMode="FlipXY" Stretch="None" Viewbox="0,0,1,1" Viewport="0,0,0.3,0.3" /> 

    </Grid.Background> 

    <DockPanel Name="dockPanel1" Margin="20,20,5,5 " LastChildFill="True"> 
     <StackPanel Name="stackPanel1" DockPanel.Dock="Left" Width="200" > 
      <Grid Name="grid1" Width="200" > 
       <Grid.RowDefinitions> 
        <RowDefinition Height="270" /> 
        <RowDefinition Height="155"/> 
        <RowDefinition Height="195" /> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition /> 
       </Grid.ColumnDefinitions> 
       <Canvas IsEnabled="True" Grid.Column="0" Grid.Row="0" > 
        <Rectangle Width="200" Height="260" RadiusX="10" RadiusY="10" Fill="White" Stroke="Silver" Opacity="0.5"/> 
        <ContentControl Canvas.Left="196" Canvas.Top="245" Height="50" Name="contentControl1" Width="100"> 
         <Viewport3D Name="viewport3D1" /> 
        </ContentControl> 
       </Canvas> 
       <Canvas Grid.Row="1"> 
        <Rectangle Width="200" Height="145" RadiusX="10" RadiusY="10" Fill="White" Stroke="Silver" Opacity="0.5"/> 
        <StackPanel Width="200" Height="145" VerticalAlignment="Top"> 
         <Label Height="35" Width="120" FontSize="12" FontWeight="Bold">Animation Settings</Label> 

         <Grid Name="grid10" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="76" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Column="0">Animate</Label> 
          <CheckBox Name="animateCheckBox" Grid.Column="1" Margin="0,7,0,0" Checked="animateCheckBox_Checked" Unchecked="animateCheckBox_Unchecked"></CheckBox> 
         </Grid> 

         <Grid Name="grid11" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="76" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Column="0">Show Circles</Label> 
          <CheckBox Name="showCirclesCheckBox" Grid.Column="1" Margin="0,7,0,0" IsEnabled="False" ></CheckBox> 
         </Grid> 

         <Grid Name="grid12" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="76" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Column="0" >Velocity</Label> 
          <Label Name="velocityLabel" Grid.Column="1" Content="{Binding Value, ElementName=velocitySlider}"></Label> 
         </Grid> 
         <Slider Height="30" Name="velocitySlider" Width="175" Minimum="1" Maximum="50" SmallChange="1" LargeChange="10" Value="50" IsEnabled="{Binding IsChecked, ElementName=animateCheckBox}" IsSnapToTickEnabled="True" /> 
        </StackPanel> 
       </Canvas> 
       <Canvas Name="o" IsEnabled="True" Grid.Column="0" Grid.Row="2"> 
        <Rectangle Width="200" Height="195" RadiusX="10" RadiusY="10" Fill="White" Stroke="Silver" Opacity="0.5"/> 
        <StackPanel Width="200" Height="195" HorizontalAlignment="Center" VerticalAlignment="Top"> 
         <Label Height="35" Width="93" FontSize="12" FontWeight="Bold">Brush Settings</Label> 

         <Grid Name="grid7" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="80" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Column="0">Line Width</Label> 
          <Label Name="widthLabel" Grid.Column="1" Content="{Binding Value, ElementName=widthSlider}"></Label> 
         </Grid> 
         <Slider Height="30" Name="widthSlider" Width="175" Minimum="1" Maximum="20" SmallChange="1" LargeChange="10" IsSnapToTickEnabled="True" /> 

         <Grid Name="grid8" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="80" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
         </Grid> 
         <Grid Name="grid9" Width="200" > 
          <Grid.RowDefinitions> 
           <RowDefinition /> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="80" /> 
           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Column="0">Brush Color</Label> 
          <StackPanel Name="colorPanel" Grid.Column="1" Background="Red" Width="40" Height="40" HorizontalAlignment="Left" Margin="5,0,0,0"></StackPanel> 
          <Button Grid.Column="1" Width="25" Height="25" Name="colorButton" Margin="5,0,0,0" Click="colorButton_Click">...</Button> 
         </Grid> 
        </StackPanel> 
       </Canvas> 
      </Grid> 
     </StackPanel> 
     <my:UserControl1 Height="100" Name="userControl11" Width="200" /> 
    </DockPanel> 
    <Button Name="button1" Width="80" HorizontalAlignment="Left" Margin="23,0,0,14" Click="button1_Click" Height="23" VerticalAlignment="Bottom"> 
     <StackPanel Height="Auto" HorizontalAlignment="Left" Orientation="Horizontal" Width="Auto"> 
      <Image Height="16" Source="draw.png" Stretch="Fill" Width="16" /> 
      <TextBlock FontSize="12" Margin="10,0,50,0" Text="SeLect" VerticalAlignment="Center" /></StackPanel> 
    </Button> 
</Grid> 

回答

0

它清楚地说,它无法找到该命名空间中的用户控件。所以请确认你在正确的NameSpace中有它。

如果不是这种情况,请在问题中添加更多详细信息。

1

的UserControl1也不会在一段代码您发布存在。您将在xaml文件的开头缺少一个xmlns:定义*,但没有更多详细信息,我们无法为您提供进一步帮助。

*这指定命名空间和程序集命名空间代码,然后用它来引用您的usercontrol。

xmlns:xyz="clr-namespace:Namespace.Path.To.My.Control;assembly=MyAssembly" 

和:

<xyz:UserControl1 Name="blah" />