.NET 4.7.2
I have a simple UserControl containing a custom TextBox. I am trying to only define the interface in Xaml and create the instance of the custom TextBox by specifying a FactoryMethod.
<UserControl x:Class="MyProject.TestView"
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:MyProject"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<local:IInterfaceTextBox x:FactoryMethod="local:Factories.CreateInterfaceTextBox" x:Arguments="{x:Null}" Text="{Binding Text}" CustomText="{Binding CustomText}" />
</Grid>
The Factories class:
namespace MyProject
{
public class Factories
{
public static IInterfaceTextBox CreateInterfaceTextBox() => new InterfaceTextBox();
}
}
First Error: The property "FactoryMethod" does not exist in the "http://schemas.microsoft.com/winfx/2006/xaml" namespace.
When I set xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" the error message says UserControl can not be found in http://schemas.microsoft.com/winfx/2009/xaml
Does anyone know how to solve this?
Just in case you are wondering, why I'm trying to this in the first place... I'm curios about new things :-)