Firstly, you cannot easily use abstract classes in the UserControl class hierarchy - it doesn’t work with the designer (you get the message “Unable to instantiate the message“ AbstractBase ”). The same problem, and there were some workarounds, all of which were painful .
After removing the "abstract", you should be able to reference your base class by including the namespace in your XAML definition and changing the code like this:
<local:AbstractBase x:Class="Test.ConcreteControl"
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"
xmlns:local="clr-namespace:Test"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</local:AbstractBase>
and
public partial class ConcreteControl : AbstractBase
{
public ConcreteControl()
{
InitializeComponent();
}
}
This assumes your base class is called "AbstractBase"
source
share