简体   繁体   English

如何在运行时编辑 app.xaml 文件?

[英]How do I Edit a app.xaml file in runtime?

How can I Edit a App.xaml in WPF in runtime?如何在运行时编辑 WPF 中的 App.xaml? ps.附言。 Trying to add a resource dictionary in a MergedDictionaries, but the file do not edit尝试在 MergedDictionaries 中添加资源字典,但文件未编辑

You don't edit the App.xaml file at runtime, but you can add a ResourceDictionary into the MergedDictionaries via code:您无需在运行时编辑 App.xaml 文件,但您可以通过代码将ResourceDictionary添加到MergedDictionaries中:

Application.Current.Resources.MergedDictionaries.Add(yourResourceDictionary);

I hope this helps.我希望这有帮助。

Trying to add a resource dictionary in a MergedDictionaries , but the file do not edit尝试在MergedDictionaries中添加资源字典,但文件未编辑

Modifying the actual XAML source file at runtime will have no effect on the running app.在运行时修改实际的 XAML 源文件不会对正在运行的应用程序产生影响。 That's because XAML files are compiled into BAML resources when you build, and the running app uses these BAML resources rather than the actual XAML source files.这是因为 XAML 文件在您构建时被编译为 BAML 资源,并且正在运行的应用程序使用这些 BAML 资源而不是实际的 XAML 源文件。

XAML files should be created and modified by developers at design time. XAML 文件应由开发人员在设计时创建和修改。 They are not used at runtime.它们不在运行时使用。

You can of course write to the actual source file in the project folder just like you would write to any other XML or text file, but it won't affect the running app.您当然可以像写入任何其他 XML 或文本文件一样写入项目文件夹中的实际源文件,但不会影响正在运行的应用程序。

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

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