When I add a Ribbon in WPF I get a full ribbon control. How can I hide everything except the Application Menu Button? I can do workarounds but is there any standard way to hide other panels?
I am too lazy to design my own control for this
You can clear items and set ribbon height property to 45 in Loaded
event.
<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>
Code-behind:
private void Ribbon_Loaded(object sender, RoutedEventArgs e)
{
Ribbon menu = sender as Ribbon;
menu.Height = 45;
menu.Items.Clear();
}
You can use it separate outside ribbon control but in this case you will lose style in drop down menu:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.