开发者

Using derived class for UserControl - how to eliminate blue-lining in xaml editor?

I'm trying to use a C# class derived from UserControl as the base class for some xaml pages' layout root, so I can share some common functionality. I.e. the backing class is like:

public class BaseView : UserControl
{
    // Some virtual functions I want in common ...
}

public class MyView : BaseView
{
    // Overidden functions ...
}

The xaml file then references the class like:

<jt:BaseView x:Class="ns.MyView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:jt="clr-namespace:ns"
    ...>
</jt:BaseView>

This seems to work when running, but in the xaml editor, the code is all underlined with blue squiggly lines, with a fly-over message of something like "Cannot create instance of BaseView".

If I don't do this, and use UserControl in the xmal, I get errors because the partial class generated from the xaml then has the UserControl base class and not开发者_如何学编程 my custom base class.

How do I get the editor to know about my custom base class (i.e. get rid of the blue underlines)?


The most common cause for a design time "Cannot create instance..." sort of error is that the constructor of the element is doing something that doesn't make sense or is unavailable at design time.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜