开发者

Overriding code behind layout changes by loading XAML file

开发者 https://www.devze.com 2023-01-10 16:12 出处:网络
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 XAM

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号