In my WPF app I want to make a parent class and have my child classes that are of type UserControl inherit from it. The problem is that while my set up isn't giving me any errors (in the code behind at least), I am seeing an error in my xaml.
In my xaml I have this current set up:
<local:MyBaseClass
xmlns:local="clr-namespace:Foo.Bar.MyFirstApp"
x:Class="Foo.Bar.MyFirstApp.FooUserControl"
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"
mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="850" FontSize="14">
My Base class is set up as follows:
namespace Foo.Bar.MyFirstApp
{
public abstract class MyBaseClass : UserControl
{
public readonly string MyProperty {get;}
public MyBaseClass(string myProperty)
{
MyProperty = myProperty;
}
}
}
Finally, my UserControl class (FooUserControl.xaml.cs)
namespace Foo.Bar.ScenarioEditor
{
/// <summary>
/// Interaction logic for FooUserControl.xaml
/// </summary>
public partial class FooUserControl : MyBaseClass, IMyFirstInterface
{
public FooUserControl(string myProperty)
: base(myProperty)
{
}
//... other methods and interface methods from IMyFirstInterface
}
}
I've also surfed the web and found some seemingly useful links like this one
But it gets me right where I started. Not sure what's the problem here. Any help is much appreciated. Cheers!