【发布时间】:2011-07-19 23:50:09
【问题描述】:
我正在尝试将我的ContextMenu 项目的commandParamater 绑定到表单上的另一个元素,但是无论我尝试什么,commandParamater 始终是null。
谁能告诉我如何正确绑定上下文菜单项的commandParamater?
我有什么:
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Files}">
<Grid>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Rename Folder"
Command="{Binding Path=ToggleControlVisability}"
CommandTarget="{Binding ElementName=FolderEditor}"
CommandParameter="{Binding ElementName=FolderEditor}">
</MenuItem>
</ContextMenu>
</Grid.ContextMenu>
<Label Content="{Binding Path=FolderName}"></Label>
<StackPanel Name="FolderEditor" Orientation="Horizontal"
Visibility="Hidden">
<TextBox Text="{Binding Path=FolderName}"></TextBox>
</StackPanel>
</Grid>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
【问题讨论】:
标签: .net wpf xaml binding contextmenu