Complex setters

For simple setters, we always use <Setter Property=”[property_name]” Value=”[property_value]”>. However, when the property is a complex type, I was blocked for a good 30 mins until i figured out the correct syntax. Hence, i wanted to share in case someone also encounters similar problem.

For a complex property like “TextDecoration”, the way to set it in style would be :

<Setter Property=”TextBlock.TextDecorations”>
<TextDecoration Location=”Underline” >

<Pen Brush=”Red” />



So here we set the textdecoration property in XAML, via Setter.Value element. Within this element, again we have TextDecoration.Pen object which is set using its own element. This is how we can set complex types in Setters.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s