I have rec.xaml set as an embedded resource. Here is its XAML:
<UserControl x:Class="SL.rec"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Rectangle Stroke="Red" Fill="Blue"/>
</Grid>
</UserControl>
In the main page, page.xaml.cs, I have:
string rec;
Stream s = this.GetType().Assembly.GetManifestResourceStream("SL.rec.xaml");
rec = new StreamReader(s).ReadToEnd();
Rectangle theRectangle = (Rectangle)XamlReader.Load(rec);
I get this error on the above line:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.dll
Additional information: AG_E_UNKNOWN_ERROR [Line: 4 Position: 29]
I'd like to load the rectangle into the page.xaml, which looks like this:
<UserControl x:Class="SL.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300" x:Name="_root">
<Grid x:Name="LayoutRoot" Background="White">
<Button HorizontalAlignment="Stretch" VerticalAlignment="Top" Content="Click Here" Height="50" x:Name="_button" Click="_button_click"/> </Grid>
</UserControl>
Any suggestions?