Selecting a UserControl from XAML

Posted by kmontgom on Stack Overflow See other posts from Stack Overflow or by kmontgom
Published on 2010-03-25T16:22:19Z Indexed on 2010/03/25 17:23 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

I'm working on a problem right now where I need to embed a UserControl inside another UserControl. But, I need to determine at runtime which embedded UserControl to instantiate.

This implies to me that some form of data binding and/or template selection mechanism has to be invoked, but I'm not sure how to proceed with the pure XAML approach.

If I was to do this with code, I would define some sort of container control in the parent UserControl, and then in the code-behind, implement some logic which would instantiate the appropriate child UserControl and then insert it as Content into the specified container in the parent UserControl.

Can this be done using only XAML, or is some sort of code-behind required?

© Stack Overflow or respective owner

Related posts about xaml

Related posts about usercontrol