Reputation: 55
I have to use RibbonMenuButton, but I need when it is clicked, the result to be as the following:
In other words, I need a grid to be opened with some buttons in it. I don't know how to do that. This is my code so far,
<RibbonMenuButton Label="{Binding AppsLabel, Source={StaticResource ribbonStrings}}"
LargeImageSource="{x:Static Member=util:ImageUtil.CGSnapToGridIcon}" x:Name="zzz" >
<Grid Height="auto" Width="auto">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<RibbonButton Grid.Row="0" Grid.Column="0" LargeImageSource="{}" Label="Reporting"></RibbonButton>
<RibbonButton Grid.Row="0" Grid.Column="1" LargeImageSource="{}" Label="Discovery"></RibbonButton>
<RibbonButton Grid.Row="0" Grid.Column="2" LargeImageSource="{}" Label="Web"></RibbonButton>
<RibbonSeparator Grid.Row="1" Grid.ColumnSpan="3"></RibbonSeparator>
<RibbonButton Grid.Row="2" Grid.Column="0" LargeImageSource="{}" Label="Content"></RibbonButton>
<RibbonButton Grid.Row="2" Grid.Column="1" LargeImageSource="{}" Label="Delete"></RibbonButton>
</Grid>
</RibbonMenuButton>
but the whole grid is highlighted when the content pops up and a grey line (for the menu items) is shown on the left side. I need to get rid of them. Please help.
Upvotes: 0
Views: 695
Reputation: 55
I've found how to do that, here is the solution:
I've put the grid inside <ItemsControl>
and after that I've applied style to it as follows:
<Style TargetType="{x:Type ItemsControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RibbonMenuItem}">
<ContentPresenter Content="{TemplateBinding Header}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
This simply makes the grid (or whatever is inside the <RibbonMenuButton>
) unselectable and as a result the content appears as a normal control but not as a RibbonMenuItem.
Upvotes: 1