I just came accross a nasty gotcha with the Visual Studio 2008 WPF designer (Cider). When setting the TextDecorations property for a control using a trigger, the following code will work at runtime, but the designer will complain with “Must specify both Property and Value for Setter. Error at object ‘System.Windows.Setter’, Line 1 Position 737″.
<ControlTemplate.Triggers>
<Trigger Property=”IsMouseOver” Value=”True”>
<Setter TargetName=”contentSite” Property=”TextDecorations” Value=”Underline”/>
</Trigger>
</ControlTemplate.Triggers>
To prevent the designer complaining, you have to use the full syntax for setting TextDecorations, as below:
<ControlTemplate.Triggers>
<Trigger Property=”IsMouseOver” Value=”True”>
<Setter TargetName=”contentSite” Property=”TextDecorations”>
<Setter.Value>
<TextDecorationCollection>
<TextDecoration Location=”Underline” />
</TextDecorationCollection>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
This seems to keep the designer happy and behaves the same at runtime as the first example - looks like there’s a bug in the converter for TextDecorations somewhere that’s causing this…