如何在 RibbonButton.Click 上提高 DataGrid.LostFocus?
以下代码使用 ToolBar 并正确导致 DataGrid.LostFocus(通过在执行命令之前提交任何未提交的行编辑);
<Toolbar FocusManager.IsFocusScope="False">
<Button Command="{Binding CommandName}" />
</ToolBar>
<DataGrid ... />
但是,我现在尝试使用 Ribbon(oct10 版本)执行相同的操作,但以下内容不会导致 DataGrid.LostFocus 引发;
<Ribbon>
<RibbonTab>
<RibbonGroup FocusManager.IsFocusScope="False">
<RibbonButton Command="{Binding CommandName}" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
<DataGrid ... />
如何使用功能区引发此事件?我尝试将 IsFocusScope 移动到其他级别(Ribbon、RibbonTab、RibbonButton),但无济于事。
The following code uses a ToolBar and correctly causes DataGrid.LostFocus (there by committing any uncomitted row-edits before the command is executed);
<Toolbar FocusManager.IsFocusScope="False">
<Button Command="{Binding CommandName}" />
</ToolBar>
<DataGrid ... />
However, I am now trying to do the same using the Ribbon (oct10 release), but the following does not cause DataGrid.LostFocus to be raised;
<Ribbon>
<RibbonTab>
<RibbonGroup FocusManager.IsFocusScope="False">
<RibbonButton Command="{Binding CommandName}" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
<DataGrid ... />
How can I raise this event using the Ribbon? I have tried moving the IsFocusScope through the other levels (Ribbon, RibbonTab, RibbonButton) to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不喜欢这个,因为需要后台代码,但没有任何其他答案;
以及后面的代码;
Don't like this due to the need for code behind, but in the absence of any other answers;
And the code behind;
虽然这个问题已经有6年多了,但我也想发布我的解决方案:
只需将 PreviewMouseDown 的事件处理程序添加到 RibbonWin 并将焦点设置为 null...
Altough this question is over 6 years old, I want to post my solution too:
Just add an Eventhandler for PreviewMouseDown to the RibbonWin and set the focus to null...