Problem

Global style is not applied as expected on the RibbonControl

Posted 1 year ago by Avatar Shraddha Kulkarni

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 1 year ago by Actipro Software Support - Cleveland, OH, USA

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 1 year ago by Shraddha Kulkarni

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 1 year ago by Actipro Software Support - Cleveland, OH, USA

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
Information The latest build of this product (2018.1 build 0672) was released 27 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.