我有RibbonApplicationMenu在我的应用程序类似于此示例:不同的行为命令
<RibbonApplicationMenu>
<RibbonApplicationMenuItem Header="Open Project..." Command="{Binding OpenProjectCommand}" />
<RibbonApplicationMenuItem Header="Save Project..." Command="{Binding SaveProjectCommand}" />
<RibbonApplicationMenuItem Header="Exit" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RibbonWindow}}}" />
<RibbonApplicationMenu.FooterPaneContent>
<RibbonButton Label="Exit" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RibbonWindow}}}" />
</RibbonApplicationMenu.FooterPaneContent>
</RibbonApplicationMenu>
private void CloseWindow (Object parameter)
{
((Window) parameter).Close();
}
在该例子中存在具有通过相同的参数绑定到相同的命令和RibbonApplicationMenuItem项RibbonButton和。该命令执行CloseWindow()函数。我感到好奇的是,当单击RibbonApplicationMenuItem时,该函数的参数是指向RibbonWindow的指针。但是,单击RibbonButton时,该函数的参数为空。
为什么行为会有所不同?
会是什么把一个关闭按钮在页脚的正常方式? –
我想说第二个选项。 (对不起,延迟!) – Dusan
第二个选项解决了我的问题。奇怪的是,即使它找不到我的CloseWindowCommand,我在Output窗口中也没有绑定错误。 –