[英]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.