Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.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# 将Usercontrol欺骗为允许"&引用;名称空间_C#_Wpf_Controls - Fatal编程技术网

C# 将Usercontrol欺骗为允许"&引用;名称空间

C# 将Usercontrol欺骗为允许"&引用;名称空间,c#,wpf,controls,C#,Wpf,Controls,我有一个第三方控件(Visifire),它的命名空间使用“.”格式。这在WPF应用程序中可以正常工作,但在UserControl中不行,因为如果您尝试包含名称空间,它会生成“找不到程序集”。这意味着我必须使用代码来添加控件、设置绑定等等,这非常烦人,因为我更喜欢使用XAML。 我的想法是使用以下方法欺骗用户控件: namespace MyControl { public class MyChart : Visifire.Charts.Chart { public MyChart

我有一个第三方控件(Visifire),它的命名空间使用“.”格式。这在WPF应用程序中可以正常工作,但在UserControl中不行,因为如果您尝试包含名称空间,它会生成“找不到程序集”。这意味着我必须使用代码来添加控件、设置绑定等等,这非常烦人,因为我更喜欢使用XAML。 我的想法是使用以下方法欺骗用户控件:

namespace MyControl
{
  public class MyChart : Visifire.Charts.Chart
  {
     public MyChart () : base() {}
  }

  public partial Chart : UserControl
  {
    // All the control stuff goes here
  }
}
然后,在XAML中,我将使用:

xmlns:local="clr-namespace:MyControl"

<Grid>
    <local:MyChart>
    </local:MyChart>
</Grid>
xmlns:local=“clr命名空间:MyControl”
这似乎不起作用,因为它会生成一个异常。 有没有人能告诉我该怎么做?多谢

您可以使用:

<Grid xmlns:charts="clr-namespace:Visifire.Charts;assembly=Visifire">
    <charts:Chart>...</charts:Chart>
</Grid>

...
要导入完全限定的命名空间,这对您不起作用吗