Friday, 25 May 2012

WPF Property Value Precedence and Style Setter

My DataTrigger / Setter was not changing the StrokeThickness property because it was exclicitly set in the Rectange tag. Property Value Precedence meant that the Setter was being overriden by the explicit property value. Moving the StrokeThickness default value into its own Setter fixed my problem.

      <Style TargetType="{x:Type Rectangle}">
         <Setter Property="StrokeThickness"
                  Value="1" />
            <DataTrigger Binding="{Binding Path=Selected}"
               <Setter Property="StrokeThickness"
                        Value="2" />

No comments: