I am having problems deserializing a xaml file and get the following error
My code is as follows:
private void SerializeToXML()
{
FileStream filestream = File.Create(@"H:\test1.xaml");
StreamWriter streamwriter = new StreamWriter(filestream);
foreach (ListViewItem Item in slideListView.Items)
{
string mystrXAMLWrite = XamlWriter.Save(Item.Tag);
streamwriter.Write(mystrXAMLWrite);
}
streamwriter.Close();
filestream.Close();
}
private void DeSerialize()
{
FileStream filestream = File.Open(@"H:\test1.xaml", FileMode.Open);
XamlReader reader = new XamlReader();
slideListView = (ListView)reader.LoadAsync(filestream);
}
If I go to the XAML file after saving and change the various names it has problems with, for example changing slideCanvas to slideCanvas1 and ContextMenu to ContextMenu1, then it will load. But obviously this is not a solution and it also means that whatever is loaded back in is not pointing to the correct bits of code as they have had numbers added to the values.
Does anyone know what I need to do here?
UPDATED
Here is the xaml produced when saving one slide object
<Slide imageZIndex="0" editText="False" ClipToBounds="True" xmlns="clr-namespace:StoryboardTool;assembly=StoryboardTool" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><av:Canvas Background="#FFFFFFFF" Name="slideCanvas" /></Slide>
If I try to place this in a Slide Object for example
Var obj = (Slide)reader.LoadAsync(filestream);
I get this XmalParseExceptionOccured problem.