我想在datagrid中为Filters创建子上下文菜单。我怎样才能做到这一点?这是我的代码:
<DataGrid x:Name="DataGridSuppliers" Margin="10" ItemsSource="{Binding}" IsReadOnly="True" >
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Create Supplier" Click="btnCreateSupplier_Click" />
<MenuItem Header="Edit Supplier" Click="btnEditSupplier_Click" />
<MenuItem Header="Filters" />
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
答案 0 :(得分:3)
在过滤器中创建嵌套子menuItems,这就是你想要的全部内容:
<ContextMenu>
<MenuItem Header="Create Supplier" Click="btnCreateSupplier_Click"/>
<MenuItem Header="Edit Supplier" Click="btnEditSupplier_Click"/>
<MenuItem Header="Filters">
<MenuItem Header="Sub Filter 1"/>
<MenuItem Header="Sub Filter 2"/>
<MenuItem Header="Sub Filter 3"/>
</MenuItem>
</ContextMenu>