C# – How to create a WPF dialog on runtime

.netc++wpf

My current project creates UI by WPF at runtime. Everything works well. The only issue about it is that the global WPF template is ignored for some reason.

We created a skin that is attached to the main form and thus used by all xaml created UI elements.

My own code just dynamically creates items like this:

var textBox = new TextBox();
parentControl.Controls.Add(textBox);

How can I accomplish this?

Best Solution

If your skins are added to the resource dictionary of your main window, the child window will not be able to see the skins. You need to move the skins to App.xaml.