我有以下XAML:如何在XAML中设置CommandParameter?
<dxg:GridControl Name="theGrid" DataSource="{Binding Path=Groupings}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem x:Name="gridprint" Command="{Binding Path=GridPrintCommand}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
</dxg:GridControl>
当GridPrintCommand执行,它的参数到GridPrintCommand.Execute(PARAM)方法为空。我想将参数设置为网格控件。我可以这样做在这样的代码隐藏:
gridprint.CommandParameter = theGrid;
这工作正常。但是我试图在XAML中设置相同的东西(CommandParameter),而我却无法把它做好!我放的所有东西都会导致BindingExpressionError或null参数。我错过了什么?
非凡!谢谢。 – Matt 2011-03-09 09:16:29
谢谢,经过三天的搜索,我发现** ContextMenus不是WPF正常VisualTree的一部分,因此您必须使用PlacementTarget进行绑定以获取ContextMenu附加到的对象** – ganchito55 2016-04-01 23:42:34