WPF如何获取ContextMenu的源控件属性
有一个DataTemplate是绑定到一个DataView上的,代码如下:
<DataTemplate x:Key="FriendTemplate">
<Grid >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label Content="{Binding Path=fusername}" Name="fname" Grid.Row="0"/>
<Label Content="{Binding Path=status}" Name="status" Grid.Row="0" />
</StackPanel>
<Label Content="{Binding Path=remark}" Name="remark" Grid.Row="1"/>
<Grid.ContextMenu>
<ContextMenu Name="rightMenu" StaysOpen="True">
<MenuItem Header="好友资料" Click="MenuItem_Click_ContactInfo" Name="contactInfo" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
</DataTemplate>
请问在这个contactInfo点击后如何获取那个label的name属性值?
<DataTemplate x:Key="FriendTemplate">
<Grid >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label Content="{Binding Path=fusername}" Name="fname" Grid.Row="0"/>
<Label Content="{Binding Path=status}" Name="status" Grid.Row="0" />
</StackPanel>
<Label Content="{Binding Path=remark}" Name="remark" Grid.Row="1"/>
<Grid.ContextMenu>
<ContextMenu Name="rightMenu" StaysOpen="True">
<MenuItem Header="好友资料" Click="MenuItem_Click_ContactInfo" Name="contactInfo" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
</DataTemplate>
请问在这个contactInfo点击后如何获取那个label的name属性值?
...全文
相关推荐
WPF中鼠标左键单击Button弹出ContextMenu,让其右键ContextMenu失效
NULL 博文链接:https://syxc.iteye.com/blog/649945
【愚公系列】2023年10月 WPF控件专题 ContextMenu控件详解
WPF控件是Windows Presentation Foundation(WPF)中的基本用户界面元素。它们是可视化对象,可以用来创建各种用户界面。WPF控件可以分为两类:原生控件和自定义控件。原生控件是由Microsoft提供的内置控件,如Button、TextBox、Label、ComboBox等。这些控件都是WPF中常见的标准用户界面元素。自定义控件则允许开发人员使用XAML和C#等编程语言来创建个性化的用户界面元素。自定义控件可以根据需求提供更多的功能和自定义化选项,以及更好的用户体验。
wpf中给 treeview 添加 CheckBox和 ContextMenu
在wpf中给treeview动态添加子节点,子节点带有checkbox,和右键弹出菜单。
ContextMenu(wpf)
WPF 以Textbox为例,进行ContextMenu的一些动作,比较简单易懂 右键菜单,文本框
WPF:ContextMenu再次罢工。 DataContext未更新
当其父级的数据上下文更改时,ContextMenu的数据上下文不会更新


