I have a DataGrid bound to a collection view model. The element view model has a property called UI of type UIElement. The scenario is that I want the generated UIElement to be bound.
So for example (imaginary toy example), say the UIElement is a TextBlock with a text Foo, then I want the DataGrid to have rows of TextBlock‘s with the text Foo.
The reason why I want this is not important here.
So how might one databind to a property of type UIElement where the UIElement is injected as the databound content?
Well, you can just go ahead and do it I guess.
This small piece of code pretty much does what you want i believe..
XAML:
Code-behind: