Replies: 2 comments 6 replies
-
|
Did you try using |
Beta Was this translation helpful? Give feedback.
5 replies
-
|
At first glance I notice two problems:
Furthermore, it would be advisable to use Flyout because ContextMenu will probably be deprecated in the future. To solve the problem you should do something like this pseudo xaml: <Window ...
xmlns:vm="using:MyApp.ViewModel"
x:DataType="vm:MainViewModel"
Name="root">
<Window.Recources>
<ControlTheme x:Key="ViewsTheme"
TargetType="MenuItem"
BasedOn="{StaticResource {x:Type MenuItem}}"
x:DataType="vm:ColumnViewModel">
<Setter Property="Header" Value="{Binding Header}"/>
<Setter Property="Command" Value="{Binding ToggleColumnCommand}"/>
</ControlTheme>
<Window.Recources>
<Window.Styles>
<Style Selector="DataGridColumnHeader">
<Setter Property="Flyout">
<MenuFlyout>
<MenuItem Header="View" ItemsSource="{Binding #root.((vm:MainViewModel)DataContext).ColumnVisibilities}"
Theme={StaticResource ViewsTheme}/>
</MenuFlyout>
</Setter>
</Style>
</Window.Styles>
<Window.DataContext>
<vm:MainViewModel/>
</Window.DataContext>
...
<DataGrid ItemsSource="{Biding Rows}">
...
</DataGrid>
</Window/> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a context menu on a DataGridColumnHeader:
This works, but I want to populate from ColumnVisibilities without the "View" menu item, i.e. have the ColumnVisibilities menu items show up in the root of the context menu.
I tried:
which populates the context menu with the items, but with an extra margin at the left and disabled.
How can I get the menu items to show up in the context menu root like they show up in the sub-menu of the "View" menu item?
Beta Was this translation helpful? Give feedback.
All reactions