2010-07-24 5 views
-2

i créer usercontrol quand je l'ajouter sur mes fenêtres WPF obtenir cette erreur: Erreur 47 La balise 'UserControl1' n'existe pas dans l'espace de noms XML 'clr-namespace: WPFTestApp; assemblage = WPFTestApp. Ligne 115 Position 14.WPF UserControl Erreur


<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> 

Répondre

0

Il dit clairement qu'il ne peut pas trouver le usercontrol dans cet espace. Alors s'il vous plaît vérifiez que vous l'avez dans le bon NameSpace.

Si ce n'est pas le cas, veuillez ajouter plus de détails à la question.

1

UserControl1 n'existe pas dans le bout de code que vous avez signalé. Il vous manquera une définition de xmlns: * au début de votre fichier xaml, mais sans plus de détails, nous ne pouvons rien faire pour vous aider. * Ceci spécifie l'espace de nommage et l'assemblage du code d'espace de noms, que vous utilisez ensuite pour référencer votre commande usercontrol.

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

et:

<xyz:UserControl1 Name="blah" />