0

I'm developing a WPF application using Catel & Orchestra Framework as I did in past.

In this particular application, it seems that if I don't specify the style inside the UserControl's resouces it doesn't apply

So I've to do in each view

  <Grid.Resources>


            <Style TargetType="TextBlock">
                <Setter Property="VerticalAlignment"
                        Value="Center" />
            </Style>
  <Grid.Resources>

And here's my Application.Xaml's resources

    <Application.Resources>
    <telerik:EnumToBooleanConverter x:Key="EnumToBooleanConverter"></telerik:EnumToBooleanConverter>
    <telerik:InvertedBooleanConverter x:Key="InvertedBooleanConverter"></telerik:InvertedBooleanConverter>
    <telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></telerik:BooleanToVisibilityConverter>
    <system:Double x:Key="Width">250</system:Double>
    <GridLength  x:Key="DefaultRowWidth">250</GridLength>
    <GridLength  x:Key="DefaultRowHeigth">40</GridLength>
    <Style TargetType="TextBlock">
        <Setter Property="VerticalAlignment"
                Value="Center" />
    </Style>

    <Style TargetType="CheckBox">
        <Setter Property="VerticalAlignment"
                Value="Center" />
    </Style>

    <Style TargetType="TextBox">
        <Setter Property="Height" Value="30"></Setter>
    </Style>
    <Style TargetType="{x:Type telerik:RadComboBox}">
        <Setter Property="Height" Value="30"></Setter>
    </Style>

    <Style TargetType="{x:Type telerik:RadDatePicker}">
        <Setter Property="Width" Value="120"></Setter>
        <Setter Property="Height" Value="30"></Setter>
    </Style>
</Application.Resources>

The enums, static values and so on are correctly recognized and used, in the case of the TextBlock/CheckBoxes and so on, no. I'm also using the FluentRibbon and Telerik as UI component (as I did in past).

Any suggestion?

Here's the layout without in user control's resource

enter image description here

and with it

enter image description here

advapi
  • 3,661
  • 4
  • 38
  • 73
  • Please give an example of what you mean. See https://stackoverflow.com/help/minimal-reproducible-example. – Chayim Friedman Aug 29 '19 at 05:49
  • Do you have two styles applied to checkboxes etc.? Does it work inside the usercontrol? maybe give us a link to the full code of the usercontrol/app.xaml. – Chayim Friedman Aug 29 '19 at 06:30
  • If I put the style inside the usercontrol, it works. The App.xaml code is all here... nothing more – advapi Aug 29 '19 at 07:09

1 Answers1

0

You are probably using the StyleHelper which creates all the styles for you (based on naming convention, Default[ControlName]Style (e.g. DefaultTextBlockStyle). Orchestra does provide all of these styles out of the box, and you need to override them on the right layer to make sure they win.

You have a few options:

  1. Specify your own version of DefaultTextBlockStyle and it should work.
  2. Disable the StyleHelper / style forwarders
  3. Override the style on a lower level (e.g. the user control level)
Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32