Inheriting from a UserControl abstract subclass

情到浓时终转凉″ 提交于 2019-12-06 12:25:09

You need to change the XAML a bit to prefix the UserControl declaration with a namespace:

<local:MyBaseControl x:Class="MyNameSpace.MyControl"
    xmlns:local="clr-namespace:MyNameSpace"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Content -->
</local:MyBaseControl>

Where MyNameSpace is your namespace (duh!), MyBaseControl is your base class and MyControl is your control that inherits from MyBaseControl. The x:Class part doesn't need to be in the same namespace, I've just kept it the same for the example.

More info here and here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!