开发者

Wpf UserControl Error

开发者 https://www.devze.com 2023-01-08 21:46 出处:网络
i create usercontrol when i add it on my wpf windows get this error: Error 47 The tag \'UserControl1\' does not exist in XML namespace \'clr-namespace:WPFTestApp;assembly=WPFTestApp\'. Line 115 Positi

i create usercontrol when i add it on my wpf windows get this error: Error 47 The tag 'UserControl1' does not exist in XML namespace 'clr-namespace:WPFTestApp;assembly=WPFTestApp'. Line 115 Position 14.


    <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>
       开发者_如何学JAVA                     <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>


UserControl1 also doesn't exist in the piece of code you posted. You will be missing an xmlns: definition* at the start of your xaml file, but without more details there is nothing we can do to help you further.

*this specifies the namespace and assembly the namespace code, which you then use to reference your usercontrol.

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

and:

<xyz:UserControl1 Name="blah" /> 


It clearly says that it cant find the usercontrol in that namespace. So please verify you have it in the right NameSpace.

If that is not the case please add more details to the question.

0

精彩评论

暂无评论...
验证码 换一张
取 消