Say I have the following 2 DataTemplates defined -
<DataTemplate x:Key="DataTemplateA">
<StackPanel Orientation="Horizontal">
<Button>swap</Button>
<TextBlock Text="this is template a"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="DataTemplateB">
<StackPanel Orientation="Horizontal">
<Button>swap</Button>
<TextBlock Text="this is template b"/>
</StackPanel>
</DataTemplate>
Is it possible to make the button 'swap' one DataTemplate for another? I want the user to be able to hit a button to change the rendering of an Item in an ItemsControl but I only want to switch that item - not the entire ItemsControl template. Do I need to make a single DataTemplate that internally switches between the 2 modes via a property of the Item itself?
<DataTemplate x:Key="DataTemplateA">
<StackPanel Orientation="Horizontal">
<Button>swap</Button>
<TextBlock Text="this is template a"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="DataTemplateB">
<StackPanel Orientation="Horizontal">
<Button>swap</Button>
<TextBlock Text="this is template b"/>
</StackPanel>
</DataTemplate>
Is it possible to make the button 'swap' one DataTemplate for another? I want the user to be able to hit a button to change the rendering of an Item in an ItemsControl but I only want to switch that item - not the entire ItemsControl template. Do I need to make a single DataTemplate that internally switches between the 2 modes via a property of the Item itself?