advapi
advapi

Reputation: 3907

Need to specify TextBox style on each view in WPF

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

Upvotes: 0

Views: 166

Answers (1)

Geert van Horrik
Geert van Horrik

Reputation: 5724

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)

Upvotes: 0

Related Questions