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 pro开发者_运维百科perty (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 ContentControl
instead of UserControl
and provide Content
in runtime by introducing a DataTemplateSelector
which able to provide right DataTemplate
in runtime?
You can encapsulate your Content-area controls in DataTemplates
and select appropriate one in runtime.
精彩评论