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…
2 responses so far ↓
Brian Pepin (MSFT) // April 16, 2008 at 4:01 pm |
This looks like a bug. It’s likely Cider isn’t correctly dealing with type converters on collections. This is a fairly rare construct and we likely missed it. We’ll have a look.
Will // April 16, 2008 at 4:42 pm |
Thanks Brian – very impressed that you picked up on the post!