I've got an application that reads in XAML files dynamically like this:
StreamReader sr = new StreamReader(pathAndFileName);
this.Content = XamlReader.Load(sr.BaseStream);
In one of those XAML files that gets loaded in (they all have had their code behind removed), this works:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DynamicXaml123">
<StackPanel Margin="10" HorizontalAlignment="Left">
<TextBox Height="23" Width="100" Text="{Binding FirstName}" />
<TextBox Height="23" Width="100" Text="{Binding LastName}" />
<TextBox Height="23" Width="100" Text="{Binding Age}" />
<local:FieldEmailView></local:FieldEmailView>
</StackPanel>
</UserControl>
But this give the error "The tag 'FieldEmailView' does not exist in XML namespace 'clr-namespace:DynamicXaml123;assembly=DynamicXaml123'".
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DynamicXaml123;assembly=DynamicXaml123">
<StackPanel Margin="10" HorizontalAlignment="Left">
<TextBox Height="23" Width="100" Text="{Binding FirstName}" />
<TextBox Height="23" Width="100" Text="{Binding LastName}" />
<TextBox Height="23" Width="100" Text="{Binding Age}" />
<local:FieldEmailView></local:FieldEmailView>
</StackPanel>
</UserControl>
If I leave out the assembly reference then it gets the error
Message=""XmlNamespace", "Assembly" oder "ClrNamespace"
when reading in the XAML.
Why can't I include the Assembly reference here, what do I have to change/check to get this to work?