NetoTI
NetoTI

Reputation: 171

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

How can I Edit a App.xaml in WPF in runtime? ps. Trying to add a resource dictionary in a MergedDictionaries, but the file do not edit

Upvotes: 1

Views: 792

Answers (2)

mm8
mm8

Reputation: 169240

Trying to add a resource dictionary in a MergedDictionaries, but the file do not edit

Modifying the actual XAML source file at runtime will have no effect on the running app. 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 files should be created and modified by developers at design time. 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.

Upvotes: 0

Keithernet
Keithernet

Reputation: 2509

You don't edit the App.xaml file at runtime, but you can add a ResourceDictionary into the MergedDictionaries via code:

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

I hope this helps.

Upvotes: 1

Related Questions