Answer the question
In order to leave comments, you need to log in
How to call the same context menu for each element with the same type?
I know how to call the context menu for a single element:
<Button Content="12345">
<Button.ContextMenu>
<ContextMenu Name="cm">
<MenuItem Header="File"/>
<MenuItem Header="Save"/>
<MenuItem Header="SaveAs"/>
<MenuItem Header="Recent Files">
<MenuItem Header="ReadMe.txt"/>
<MenuItem Header="Schedule.xls"/>
</MenuItem>
</ContextMenu>
</Button.ContextMenu>
</Button>
Answer the question
In order to leave comments, you need to log in
Perhaps this option will work for you:
<Window.Resources>
<ContextMenu x:Key="MyContextMenu">
<!--Ваше меню -->
</ContextMenu>
</Window.Resources>
<Grid>
<!-- колонки строки -->
<TextBox Tag="1" Grid.Column="1" Grid.Row="5" ContextMenu="{StaticResource MyContextMenu}"/>
<TextBox Tag="2" Grid.Column="2" Grid.Row="5" ContextMenu="{StaticResource MyContextMenu}"/>
</Grid>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question