我尝试将itemssource
(集合中的集合)绑定到上下文菜单,我想通过单击(MVVM)Caliburn
<TreeView x:Name="TreeViewName" BorderThickness="0" ItemsSource="{Binding RegionsTree}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<RadioButton Tag="{Binding DataContext, ElementName=TreeViewName}" Content="{Binding Name}"
cal:Message.Attach="[Click]=[ShowItemScreen($dataContext)];[PreviewMouseRightButtonDown]=[Action OnContextMenuOpening($source)]"
GroupName="TestTree">
<RadioButton.ContextMenu>
<ContextMenu ItemsSource="{Binding RegionCategories}" cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="MenuItem.Header" Value="{Binding Name}" />
<Setter Property="MenuItem.ItemsSource" Value="{Binding Commands}" />
<Setter Property="cal:Message.Attach" Value="[Action ContextMenuItemClick($eventArgs)]"/>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</RadioButton.ContextMenu>
</RadioButton>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
<TreeView.ItemContainerStyle >
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>