Ribbon buttons and styles

Sep 11, 2010 at 10:25 PM

I may be all wrong, but I am trying to use styles for ribbon controls and it does not work properly for me,

The style for ordinary button sets Text correctly, but the second style for fluent button does not work (the button is not visible at all)

here is the code excerpt:

    <DockPanel>
        <DockPanel.Resources>
            <Style TargetType="{x:Type Fluent:Button}" x:Key="ribbonButtonCommandStyle" >
                <Setter Property="Text"    Value="asdf" />
            </Style>
            <Style TargetType="{x:Type Button}" x:Key="ribbonButtonCommandStyle2" >
                <Setter Property="Content"    Value="asdf" />
            </Style>
        </DockPanel.Resources>

        <Button DockPanel.Dock="Top" Style="{StaticResource ResourceKey=ribbonButtonCommandStyle2}" ></Button>
        <Fluent:Ribbon DockPanel.Dock="Top">
            
            <Fluent:Ribbon.BackstageItems>
                <Fluent:Button x:Name="newProjectButton"
                           Icon="{StaticResource ResourceKey=GenericDocument}"
                           Command="{x:Static Gui:XCaseApplicationCommands.NewProjectCommand}"
                           Fluent:KeyTip.Keys="N"
                           Style="{StaticResource ResourceKey=ribbonButtonCommandStyle}"
                           />
Sep 12, 2010 at 10:25 PM

Oh, I forgot to add the base style...

Coordinator
Sep 13, 2010 at 1:08 PM

Yep, you need to use basedon property

Mar 28, 2012 at 8:41 PM

Could you show an example?

 

Developer
Mar 30, 2012 at 2:24 PM

<Style TargetType="{x:Type Fluent:Button}" 
       x:Key="ribbonButtonCommandStyle" 
       BasedOn="{StaticResource RibbonButtonStyle}">
    <Setter Property="Text" Value="asdf" />
</Style>

Or:

<Style TargetType="{x:Type Fluent:Button}" 
       x:Key="ribbonButtonCommandStyle" 
       BasedOn="{StaticResource {x:Type Fluent:Button}}">
    <Setter Property="Text" Value="asdf" />
</Style>