Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
-
Managed to get this working for a ListBox ItemsControl with a context menu being defined in the parent window. This made it possible to bind via ReactiveUI code-behind which is the chosen binding method in my case. In my window .axaml: <Window.Styles>
<Style Selector="ListBox#MyListBox views|CustomItemDataTemplate">
<Setter Property="ContextMenu">
<ContextMenu>
<MenuItem Name="CTXOpenFile" Header="Open File" />
<MenuItem Name="CTXOpenLocation" Header="Open Location" />
<MenuItem Name="CTXDeleteFile" Header="Delete File" />
</ContextMenu>
</Setter>
</Style>
</Window.Styles> Then in the code-behind constructor: this.WhenActivated(compDispose =>
{
this.BindCommand(ViewModel, vm => vm.OpenSelectedInDefaultProgram, v => v.CTXOpenFile)
.DisposeWith(compDispose);
}); I knew about targeting controls by name, but wasn't aware it could be done in a Style Selector. Thanks for the info regardless, hopefully this example will be able to help others as well. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a tabcontrol with a context menu:
When right-clicking on a not-selected tab header, I would like to provide the proper context to the menu, corresponding to the right-clicked header, whether selected or not. I don't want to select the header on opening the context menu.
This might be possible by specifying a command parameter in the axaml.
How do I specify the tab item as the command parameter?
{Binding} results in passing the outer datacontext:
Beta Was this translation helpful? Give feedback.
All reactions