Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用户控件和XML名称空间_C#_Xml_Wpf_Namespaces - Fatal编程技术网

C# 用户控件和XML名称空间

C# 用户控件和XML名称空间,c#,xml,wpf,namespaces,C#,Xml,Wpf,Namespaces,在WPF中使用xml名称空间(xmlns:)时,是否需要以其他方式指定名称空间?我试图实现一个用户控件,但它一直给我以下错误:“名称“”不存在于名称空间'clr namespace:myNamespace'中。” 任何关于xml名称空间的提示(特别是在尝试访问类时)都将不胜感激 更新: 在尝试将自定义用户控件添加到主窗口时,我一直遇到以下错误:“名称“customControl”不存在于名称空间“clr namespace:MovableDataGridRows\u test.userContr

在WPF中使用xml名称空间(xmlns:)时,是否需要以其他方式指定名称空间?我试图实现一个用户控件,但它一直给我以下错误:“名称“”不存在于名称空间'clr namespace:myNamespace'中。”

任何关于xml名称空间的提示(特别是在尝试访问类时)都将不胜感激

更新:

在尝试将自定义用户控件添加到主窗口时,我一直遇到以下错误:“名称“customControl”不存在于名称空间“clr namespace:MovableDataGridRows\u test.userControls”中。”

下面是我的主窗口的XAML代码:

<Window x:Class="MovableDataGridRows_test.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls_c="clr-namespace:MovableDataGridRows_test.userControls"
    Title="MainWindow" Height="350" Width="525">


    <Controls_c:customControl width="300"/>
</Window>

下面是我希望包含在主窗口中的用户控件的XAML代码(注意:用户控件位于名为“userControl”的项目文件夹中。项目名称为“MovableDataGridRows_test”):


提交

同时检查总成。您能否显示代码,以便我们有更好的机会诊断您的问题?
xmlns:custom=“clr namespace:MyNamespace;assembly=MyAssembly”
省略
;assembly=MyAssembly“
part仅在您映射的命名空间与用户控件中的命名空间位于同一程序集中时才允许使用。请检查此项。
<UserControl x:Class="MovableDataGridRows_test.userControls.UserControl1"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Button Margin="223,0,0,263">Submit</Button>
        <TextBox HorizontalAlignment="Left" Height="37" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="223"/>
    </Grid>
</UserControl>