views:

159

answers:

1

Hey

I have an Ellipse defined as so

<Ellipse Stroke="#FF474747" Style="{StaticResource SelectedTemplate}" Fill="{StaticResource RedGradient}" />

I also have two styles setup like so

<RadialGradientBrush x:Key="RedGradient" GradientOrigin="1,1">
    <GradientStop Color="White"/>
    <GradientStop Color="Red" Offset="1"/>
</RadialGradientBrush>

<RadialGradientBrush x:Key="GreenGradient" GradientOrigin="1,1">
    <GradientStop Color="White"/>
    <GradientStop Color="Green" Offset="1"/>
</RadialGradientBrush>

Now, when the Ellipse is first drawn it is Red as per the RedGradientBrush. I want to make the ellipse green when a binded value (Selected) is true so I added a Style to do this

<Style x:Key="SelectedTemplate" TargetType="Ellipse">
 <Style.Triggers>
  <DataTrigger Value="True" Binding="{Binding Selected}">
   <Setter Property="Stroke" Value="White" />
   <Setter Property="StrokeThickness" Value="5" />
   <Setter Property="Fill" Value="{StaticResource GreenGradient}" />
  </DataTrigger>
 </Style.Triggers>
</Style>

Now, when Selected is True ONLY the StrokeThickness changes, nothing else? Can anyone help please?

Thanks

A: 

Apparently XAML inline styles override any you set. This is why only the StrokeThickness was being changed as it wasn't set inline.

Chris