In my application I'd like to create a fading line that has GradientStop
s with system colors, I'm trying to do it like this:
<UserControl.Resources>
<Style x:Key="Divider" TargetType="Rectangle">
<Setter Property="Height" Value="2" />
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{StaticResource PhoneChromeBrush}" Offset="0.0" />
<GradientStop Color="{StaticResource PhoneInverseBackgroundBrush}" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
But when I try to compile project I get the following error:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll
An exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll but was not handled in user code
What should I do to fix this?
GradientStop.Color
expects a color, not a brush. Use PhoneChromeColor
and PhoneInverseBackgroundColor
instead:
<UserControl.Resources>
<Style x:Key="Divider" TargetType="Rectangle">
<Setter Property="Height" Value="2" />
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{StaticResource PhoneChromeColor}" Offset="0.0" />
<GradientStop Color="{StaticResource PhoneInverseBackgroundColor}" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>