我已經看到它完成的方式,使用Windows功能區控件:額外的按鈕必須在設計時在XML標記中指定。在運行時,您可以撥打SetModes()
指定在功能區中顯示哪些組件。
像這樣:
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab CommandName="cmdTabMain" ApplicationModes="0,1">
<Group CommandName="cmdGroupCommon"
SizeDefinition="ThreeButtons"
ApplicationModes="0,1">
<Button CommandName="cmdButtonNew" />
<Button CommandName="cmdButtonOpen" />
<Button CommandName="cmdButtonSave" />
</Group>
<Group CommandName="cmdGroupSimple"
SizeDefinition="TwoButtons"
ApplicationModes="0">
<Button CommandName="cmdButtonSwitchToAdvanced" />
<Button CommandName="cmdButtonDropA" />
</Group>
<Group CommandName="cmdGroupAdvanced"
SizeDefinition="FourButtons"
ApplicationModes="1">
<Button CommandName="cmdButtonSwitchToSimple" />
<Button CommandName="cmdButtonDropA" />
<Button CommandName="cmdButtonDropB" />
<Button CommandName="cmdButtonDropC" />
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
然後(在C#反正)單擊處理程序,你做_ribbon.SetModes(1)
或_ribbon.SetModes(0)
。

謝謝!你真的付出了努力,但這不是我正在尋找的東西。我正在專門尋找C++解決方案。我的問題是我不知道如何爲功能區中的特定按鈕獲取一些'IButton'接口並調用它的'IButton-> Enable(false)'方法。我希望現在更清楚。 – wpfwannabe 2011-05-09 11:10:46