The user interface of my application is designed to be configured at application startup in the Window Loaded event handler. I read a configuration, either from a config file or from a database, and, based on the predefined configuration, I want to place User Controls (or simply predefined control templates) in the Grid on my main window. The possible configurations are previously defined and the controls to be used for them are already coded in XAML and entered in a Resource dictionary.
My problem is this: After many trials using several ContentPresenter tags on the main window, I still cannot figure out how to select the correct user controls from the Resource Dictionary and get them placed where the place holders are (represented by the ContentPresenter tags).
- What attributes do I need to define on each ContentPresenter on my main window in order to be able to programmatically set the actual content?
- How do I construct the user controls and what tags do I need to define in each of them?
- Should I even use User Controls but instead simply use fully defined XAML objects in the Resource Dictionary?
- How do I then select and place the correct controls based on my app's configuration?
Any help on this is greatly appreciated!