[英]How to hide everything except Application Menu Button in WPF Ribbon?
在WPF中添加功能區時,我得到了完整的功能區控件。 如何隱藏除“應用程序菜單”按鈕以外的所有內容? 我可以解決,但是有什么標准的方法可以隱藏其他面板嗎?
我懶得為此設計自己的控件
您可以清除項目並將“ Loaded
事件中的色帶高度屬性設置為45。
<ribbon:Ribbon x:Name="Ribbon" Loaded="Ribbon_Loaded">
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Images\SmallIcon.png">
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\LargeIcon.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Group1">
<ribbon:RibbonButton x:Name="Button1"
LargeImageSource="Images\LargeIcon.png"
Label="Button1" />
<ribbon:RibbonButton x:Name="Button2"
SmallImageSource="Images\SmallIcon.png"
Label="Button2" />
<ribbon:RibbonButton x:Name="Button3"
SmallImageSource="Images\SmallIcon.png"
Label="Button3" />
<ribbon:RibbonButton x:Name="Button4"
SmallImageSource="Images\SmallIcon.png"
Label="Button4" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
后台代碼:
private void Ribbon_Loaded(object sender, RoutedEventArgs e)
{
Ribbon menu = sender as Ribbon;
menu.Height = 45;
menu.Items.Clear();
}
您可以在單獨的外部功能區控件中使用它,但是在這種情況下,您將在下拉菜單中失去樣式:
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ribbon:RibbonApplicationMenu SmallImageSource="Images\SmallIcon.png" HorizontalAlignment="Left">
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem9"
ImageSource="Images\LargeIcon.png"
/>
</ribbon:RibbonApplicationMenu>
</Grid>
/>
</ribbon:RibbonApplicationMenu>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.