Global style is not applied as expected on the RibbonControl

Ribbon for WPF Forum

Posted 7 years ago by Shraddha Kulkarni
Version: 17.1.0652
Platform: .NET 4.5
Environment: Windows 10 (64-bit)
Avatar

Hello,

We are trying to have a global style for all RibbonControls in the application. But the style is not getting applied on the ribbonwindows. Attached is the sample application. 

 

In the below sample, the global style gets applied to the TextBox but not to the RibbonWindow.

Resource fie

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"    >


    <Style TargetType="{x:Type ribbon:RibbonWindow}">
        <Setter Property="IsGlassEnabled" Value="False"/>
        <Setter Property="BorderThickness" Value="10"/>
        <Setter Property="ApplicationName" Value="Dummy Window"/>
    </Style>
    
    <Style TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="Red"/>
        <Setter Property="BorderThickness" Value="10"/>
    </Style>

</ResourceDictionary>

 

<ribbon:RibbonWindow  x:Class="WpfApplication1.MainWindow"
    x:Name="winDMLogin" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"    >

  
    <Grid>
        <StackPanel Orientation="Vertical">
            <TextBox Text="Text"></TextBox>
        </StackPanel>
    </Grid>
</ribbon:RibbonWindow>

 

Thanks.

Comments (3)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I think this is is a description of the problem you are running into here, and it offers a workaround idea:

https://stackoverflow.com/questions/4279773/wpf-window-style-not-being-applied


Actipro Software Support

Posted 7 years ago by Shraddha Kulkarni
Avatar

Hello,

This solution offers to have a key. But it will force me to use the key in all XAMLs. Which will not be a practical solution for me. I need to have the style in the common resource file, which will get applied on all the control in the solution without editing each and every xaml file. 

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Implicit styles in WPF work for targeting controls, but don't work on targeting Windows.  That's why the suggestions in that StackOverflow article would be necessary for the Window scenario.  It's unfortunately how WPF was designed by Microsoft.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.