c# WPF oval button

  1. <ControlTemplate x:Key="myButton" TargetType="Button">   
  2.     <Grid Width="{TemplateBinding ActualWidth}"   
  3.             Height="{TemplateBinding ActualHeight}" Background="#00FFFFFF">   
  4.         <Ellipse Name="Circle" StrokeThickness="1">   
  5.             <Ellipse.Fill>   
  6.                 <LinearGradientBrush EndPoint="2.2,0" StartPoint="0,0">   
  7.                     <LinearGradientBrush.GradientStops>   
  8.                         <GradientStop Offset="0" Color="LightGray" />   
  9.                         <GradientStop Offset="0.3" Color="Gray" />   
  10.                     </LinearGradientBrush.GradientStops>   
  11.                 </LinearGradientBrush>   
  12.             </Ellipse.Fill>   
  13.         </Ellipse>   
  14.         <ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center"/>   
  15.     </Grid>   
  16.     <ControlTemplate.Triggers>   
  17.         <Trigger Property="UIElement.IsEnabled" Value="false">   
  18.             <Setter Property="Shape.Fill" TargetName="Circle">   
  19.                 <Setter.Value>   
  20.                     <LinearGradientBrush EndPoint="2.2,0" StartPoint="0,0">   
  21.                         <LinearGradientBrush.GradientStops>   
  22.                             <GradientStop Offset="0" Color="#FFFFFFFF" />   
  23.                             <GradientStop Offset="0.5" Color="#FFEBEEF5" />   
  24.                             <GradientStop Offset="0.5" Color="#FFD8DDEB" />   
  25.                             <GradientStop Offset="1" Color="#FFDFE2F0" />   
  26.                         </LinearGradientBrush.GradientStops>   
  27.                     </LinearGradientBrush>   
  28.                 </Setter.Value>   
  29.             </Setter>   
  30.         </Trigger>   
  31.         <Trigger Property="UIElement.IsMouseOver" Value="true">   
  32.             <Setter Property="Shape.Fill" TargetName="Circle">   
  33.                 <Setter.Value>   
  34.                     <LinearGradientBrush EndPoint="2.2,0" StartPoint="0,0">   
  35.                         <LinearGradientBrush.GradientStops>   
  36.                             <GradientStop Offset="0" Color="#FFFFFFFF" />   
  37.                             <GradientStop Offset="0.1" Color="#FFDFEDF9" />   
  38.                             <GradientStop Offset="0.47" Color="#FF3086E1" />   
  39.                             <GradientStop Offset="0.47" Color="#FF003B91" />   
  40.                             <GradientStop Offset="0.7" Color="#FF1793EF" />   
  41.                             <GradientStop Offset="0.85" Color="#FF5AD4FF" />   
  42.                             <GradientStop Offset="0.95" Color="#FFBDFFFF" />   
  43.                             <GradientStop Offset="1" Color="#FFFFFFFF" />   
  44.                         </LinearGradientBrush.GradientStops>   
  45.                     </LinearGradientBrush>   
  46.                 </Setter.Value>   
  47.             </Setter>   
  48.         </Trigger>   
  49.         <Trigger Property="ButtonBase.IsPressed" Value="True">   
  50.             <Setter Property="Shape.Fill" TargetName="Circle">   
  51.                 <Setter.Value>   
  52.                     <LinearGradientBrush EndPoint="2.2,0" StartPoint="0,0">   
  53.                         <LinearGradientBrush.GradientStops>   
  54.                             <GradientStop Offset="0" Color="#FFC0D2F5" />   
  55.                             <GradientStop Offset="0.47" Color="#FF5E7A9C" />   
  56.                             <GradientStop Offset="0.47" Color="#FF00062D" />   
  57.                             <GradientStop Offset="0.7" Color="#FF005F9F" />   
  58.                             <GradientStop Offset="0.85" Color="#FF1FA4E2" />   
  59.                             <GradientStop Offset="0.95" Color="#FF61DAFF" />   
  60.                             <GradientStop Offset="1" Color="#FF48CFFF" />   
  61.                         </LinearGradientBrush.GradientStops>   
  62.                     </LinearGradientBrush>   
  63.                 </Setter.Value>   
  64.             </Setter>   
  65.         </Trigger>   
  66.     </ControlTemplate.Triggers>   
  67. </ControlTemplate>   

Result:


No action


IsMouseOver


IsPressed

No comments:

Post a Comment