Silverlight
WPF
Another example for WPF. Here I used triggers and resources:<Style x:Key="Button" TargetType="Button">
<Style.Resources>
<LinearGradientBrush x:Key="lgbNormal" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="{x:Static SystemColors.ControlLightLightColor}" />
<GradientStop Offset="0.5" Color="{x:Static SystemColors.ControlLightColor}" />
<GradientStop Offset="0.5" Color="{x:Static SystemColors.ControlDarkDarkColor}" />
<GradientStop Offset="1" Color="{x:Static SystemColors.ControlDarkDarkColor}" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="lgbMouseOver" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="{x:Static SystemColors.ControlLightLightColor}" />
<GradientStop Offset="0.5" Color="#083B80" />
<GradientStop Offset="0.5" Color="{x:Static SystemColors.ControlDarkDarkColor}" />
<GradientStop Offset="1" Color="{x:Static SystemColors.ControlDarkDarkColor}" />
</LinearGradientBrush>
</Style.Resources>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" BorderThickness="1" BorderBrush="#3E3E3E" CornerRadius="2">
<Grid>
<Rectangle x:Name="rect" RadiusX="2" RadiusY="2" Fill="{StaticResource lgbNormal}" />
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="rect" Property="Fill" Value="{StaticResource lgbMouseOver}" />
<Setter TargetName="border" Property="BorderBrush" Value="#083B80" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
No comments:
Post a Comment