I have three classes, of which two subclass the first:
class MyItem {}
class MyItemA : MyItem {}
class MyItemB : MyItem {}
I show MyItemA
using a DataTemplate
thus:
<DataTemplate x:Key="MyTemplate"
x:DataType="vm:MyItem">
<TreeViewItem>
<Grid ContextFlyout="{StaticResource MyItemAMenuFlyout}"
Now I wish to also add MyItemB
to the TreeView
, whith the exact same structure (as set by the MyTemplate
DataTemplate
) but with another right-click menu.
How can I do this without copying the whole MyTemplate
xaml to another and changing the ContextFlyout
? I wish to reuse the DataTemplate
I already have (it only references properties from the base class).