[英]WPF Microsoft Ribbon popup doesn't collapse
I'm having a ribbon with a menu that opens a popup, like so: 我在功能区中打开了一个弹出菜单,如下所示:
Before I clicked the button that shows the popup like the pic, some logic is triggered (irrelevant how) that changes the active tab in the ribbon. 在单击显示如图所示弹出窗口的按钮之前,会触发一些逻辑(无关紧要),这些逻辑会更改功能区中的活动选项卡。 This can occasionally result in the situation that the popup from the previous tab remained visible but a new tab is visible behind it.
有时可能会导致出现以下情况:前一个选项卡的弹出窗口仍然可见,但后面的新选项卡仍然可见。 When I mouseEnter the popup, I get a StackOverFlowException.
当我用鼠标进入弹出窗口时,我得到一个StackOverFlowException。
I was thinking of "deactivating" the previous tab or so, does anyone know what I'm doing wrong? 我当时正在考虑“停用”前一个标签,所以有人知道我在做什么错吗?
I added the following to achieve what I wanted :) This solution is implementation specific (ie based on my investigation of the implementation of the ribbon that we use). 我添加了以下内容来实现我想要的目标:)此解决方案是特定于实现的(即,基于对所使用功能区的实现的调查)。 The implementation needed a different
originalSource
which I managed to achieve by setting the Source to the RibbonWindow
instance. 该实现需要一个不同的
originalSource
,我可以通过将Source设置为RibbonWindow
实例来实现。
private void DismissRibbonPopup()
{
// Hack inspired by RibbonHelper; try to close any open RibbonPopups (implicit "from the current ActiveTab").
UIElement source = Mouse.Captured as UIElement;
if (source != null)
source.RaiseEvent(new RibbonDismissPopupEventArgs() { Source = /** I put the RibbonWindow instance here */ });
}
In my code I call this method and after that I set the new tab to IsSelected = true;
在我的代码中,我调用此方法,然后将新选项卡设置为
IsSelected = true;
This implementation differs slightly from what I came across in the impl. 此实现与我在impl中遇到的实现略有不同。 because it had little superfluous code.
因为它几乎没有多余的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.