开发者

Tricking a Usercontrol to allow "." namespaces

开发者 https://www.devze.com 2023-01-10 12:33 出处:网络
I have a 3rd party control (Visifire) which has a namespace that uses the \".\" format. This works fine in a WPF application, but not in a UserControl as it generates a \"can\'t find assembly\" if you

I have a 3rd party control (Visifire) which has a namespace that uses the "." format. This works fine in a WPF application, but not in a UserControl as it generates a "can't find assembly" if you try to include the namespace. This means I have to use code to add the control, set up the bindings, etc, etc, which is quite annoying as I would prefer to use XAML. My thought was to trick the UserControl using the following:

namespace MyControl
{
  public class MyChart : Visifire.Charts.Chart
  {
     public MyChart () 开发者_如何学Go: base() {}
  }

  public partial Chart : UserControl
  {
    // All the control stuff goes here
  }
}

Then, in XAML, I would use:

xmlns:local="clr-namespace:MyControl"

<Grid>
    <local:MyChart>
    </local:MyChart>
</Grid>

This doesn't seem to work, as it generates an exception. Anybody have any tips on how I could get around this? THanks much!


You can use:

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

To import a fully-qualified namespace, does that not work for you?

0

精彩评论

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