Alan2
Alan2

Reputation: 24572

Can I define Resources as part of a Style?

My code currently looks like this:

<Grid Style="{StaticResource HG}" >
   <Grid.Resources>
      <Style TargetType="Label">
         <Setter Property="TextColor" Value="{DynamicResource HelpTextColor}" />
         <Setter Property="Style" Value="{StaticResource HD}" />
      </Style>
</Grid.Resources>

and I have this used in a Grid like this:

<Grid Style="{StaticResource HG}" >
   <Grid.Resources>
      <Style TargetType="Label">
         <Setter Property="TextColor" Value="{DynamicResource HelpTextColor}" />
         <Setter Property="Style" Value="{StaticResource HD}" />
      </Style>
   </Grid.Resources>

Is there any way that I can combine the Grid.Resources into the Style I called HG ?

Upvotes: 0

Views: 66

Answers (1)

EvZ
EvZ

Reputation: 12179

Style has a TargetType property, which is used to determine the target control type.

HG style TagetType is Grid where the second style TargetType is a Label. Merging these 2 does not make sense.

It might be possible using CSS but I never tried that.

Upvotes: 1

Related Questions