Here is a simple example about the ContentControl and the TemplateSelector. This is really useful when you have a single model that can be represented on the UI in different ways depending on an enum for example.

This will be the final result in the UI while using the same model:

Let’s start with our model:

Now, let’s design our template selector, where the selection will be based on the enum from our model:

Let’s instanciate our model as a Header and a Value in the MainViewModel:

Last but not least, our View containing the ContentControl for our Header and Value:

If you want more examples about TemplateSelector, have a look my other post about ItemsControl here.

Happy coding! 😉