我对Microsoft CAB框架相当陌生,并且遇到了一个问题,我无法在应用程序中"取消隐藏"ribbon bar,因为它是在应用程序加载时设置的。我可以在WorkItem控制器的事件中取消隐藏/显示它,如下:
' Show Ribbon
<EventSubscription(Constants.Events.HideRibbon, ThreadOption.UserInterface)> _
Public Sub hideRibbon(ByVal sender As Object, ByVal e As EventArgs)
mShellUIExtensionService.ShowRibbon(True)
End Sub
我认为我可以在启动时加载的视图中发布上述事件,但是遗憾的是,在应用程序启动后,Ribbon栏仍然隐藏。
我公司的某人正在使用以下黑客从"ShellCreated"事件发送F1键到应用程序(我认为这是一个保留词事件,因为我可以在代码的任何地方找到事件发布),但我发现它有时可以将F1键发送到错误的应用程序,如word, Outlook等:
'This works, kind of...
'===Maximize the RibbonBar automatically on Startup===
<EventSubscription("ShellCreated", ThreadOption.UserInterface)> _
Public Sub OnShellCreated(ByVal sender As Object, ByVal e As EventArgs)
System.Windows.Forms.SendKeys.Send("^{F1}")
End Sub
我尝试添加mShellUIExtensionService.ShowRibbon(True)到上面的OnShellCreated函数,但是功能区栏仍然隐藏。
我怀疑问题在于CAB架构加载的顺序,所以有人知道如何在应用程序加载后设置CAB加载的属性吗?或者至少知道如何解决这个问题?
经过反复试验,我发现以下方法是可行的:
<EventSubscription("ShellCreated", ThreadOption.UserInterface)> _
Public Sub OnShellCreated(ByVal sender As Object, ByVal e As EventArgs)
mShellUIExtensionService.RibbonBar.IsMinimized() = False
End Sub