简体   繁体   English

C#WPF XAML加载

[英]C# WPF XAML Loading

Hi I'd like to inquire on how i can load a WPF Xaml into code so that I can change the values of the attributes of some XAML elements and output it by creating another XAML files. 嗨,我想问一下如何将WPF Xaml加载到代码中,以便可以更改某些XAML元素的属性值并通过创建另一个XAML文件将其输出。 This is so that I can output the same file with values dynamically input by the user. 这样,我就可以输出具有用户动态输入的值的相同文件。

the XamlReader.Load() method cannot be used; XamlReader.Load()方法不能使用; it will throw an exception (because they are unable to recognise Window as the root element) . 它将引发异常(因为它们无法将Window识别为根元素) I'm using VS2013 and C# . 我正在使用VS2013C#

XamlReader is the answer... just need to be aware of the trick to using it. XamlReader就是答案……只需要知道使用它的技巧即可。 See the answer to this question: Can I use XamlReader.Load or InitializeFromXaml from a WPF Window, for the Window definition? 请参见以下问题的答案:是否可以从WPF窗口使用XamlReader.Load或InitializeFromXaml作为窗口定义?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM