<ListView>
<ListView.Resources>
<DataTempalte x:Key="label">
<TextBlock Text="{Binding Label}"/>
</DataTEmplate>
<DataTemplate x:Key="editor">
<UserControl Content="{Binding Control.content}"/> <!-- This is the line -->
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Name" CellTemplate="{StaticResource label}"/>
<GridViewColumn Header="Value" CellTemplate="{StaticResource editor}"/>
</GridView>
</ListView.View>
On the marketed line, I'm replacing the contents of a UserControl with the contents of another UserControl that is dynamically created in code. I'd like to replace the entire control, and not just the content. Is there a way to do this?
Edit:
To clarify my intent, the Items
that my ListView
collection holds owns a Control (which inherits from UserControl
) that knows how to manipulate the item's value. Simply binding the Content gets me the visual representation, but discards other non-content related properties of the derived Control. If I could replace that UserControl in my template in a more whole-sale fashion, this would fix that problem.