I have a UserControl without Content, because the control which should be shown inside of the UserControl is created at runtime. I would like to solve this like follows, but don’t know how to implement it:
- Create a Control-variable in the
ViewModel - Set it at runtime when the content is created
- Bind a content property (inside the UserControl) to that variable
The problem is, that I don’t know how to bind to the control-variable.
Why just not to use
ContentControlinstead ofUserControland provideContentin runtime by introducing aDataTemplateSelectorwhich able to provide rightDataTemplatein runtime?You can encapsulate your Content-area controls in
DataTemplatesand select appropriate one in runtime.