Compile/Execute XAML during program runtime

后端 未结 3 1302
悲哀的现实
悲哀的现实 2020-12-12 02:49

I would like to create an WPF Application which retrieves XAML Code from a Database and displays the retrieved code.

Lets say the database return the following code:

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 03:28

    This is an old question, but I want to suggest a better way without compiling in runtime.

    1. Replacing the "click" attribute with "Command". Implement your Relay command or other third party libraries ( Eg: MVVM Light toolkit ) . Also ICommand MVVM implementation would help.
    2. Remove x:Class attribute from xaml of Window node.

    Now you have a loose xaml and task could be done by XamlReader.

提交回复
热议问题