I have a WPF app in which my client wants to be able to write a custom xml file to change the default layout set by an existing XAML file. What I am trying to do is fall back to the XAML layout if there are errors in the xml file I am parsing. I have the code behind done for parsing the xml file and changing the default layout but I'm trying to find a way to load the XAML file if something goes wrong. Is this at all possible?
A:
If you need an ability to load a layout dynamically, here is one possible solution. This can be achieved by using the XamlReader class. The process is quite straightforward, just use the XamlReader.Load method to load a serialized content from a stream (xml or whatever).
However, i can't see why you don't want to just validate the user-defined xml file, and if something is wrong, don't do anything.
n535
2010-08-05 22:18:11
Yeah, your suggestion about validating the xml file is what I was leaning towards but it made me curious about other ways to do it. Thanks for the reply.
Brian
2010-08-05 22:28:10