sammarks

XAML Code for my Button Style

Jul 10th, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.90 KB | None | 0 0
  1. <Style x:Key="UserMenuButton" TargetType="{x:Type Button}" BasedOn="{x:Null}">
  2.         <Setter Property="FocusVisualStyle" Value="{DynamicResource SimpleButtonFocusVisual}"/>
  3.         <Setter Property="Background" Value="#88BBBBBB"/>
  4.         <Setter Property="BorderBrush" Value="#FFFFFFFF"/>
  5.         <Setter Property="BorderThickness" Value="0" />
  6.         <Setter Property="Foreground" Value="#FF333333" />
  7.         <Setter Property="FontSize" Value="18pt" />
  8.         <Setter Property="FontWeight" Value="Bold" />
  9.         <Setter Property="Cursor" Value="Hand" />
  10.         <Setter Property="HorizontalContentAlignment" Value="Right" />
  11.         <Setter Property="VerticalContentAlignment" Value="Bottom" />
  12.         <Setter Property="Template">
  13.             <Setter.Value>
  14.                 <ControlTemplate TargetType="{x:Type Button}">
  15.  
  16.                     <!-- We use Grid as a root because it is easy to add more elements to customize the button -->
  17.                     <Grid x:Name="Grid">
  18.                         <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
  19.  
  20.                         <!-- Content Presenter is where the text content etc is placed by the control -->
  21.                         <!-- The bindings are useful so that the control can be parameterized without editing the template -->
  22.                         <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
  23.                     </Grid>
  24.                 </ControlTemplate>
  25.             </Setter.Value>
  26.         </Setter>
  27.         <Style.Triggers>
  28.             <EventTrigger RoutedEvent="MouseEnter">
  29.                 <BeginStoryboard>
  30.                     <Storyboard>
  31.                         <ColorAnimation To="#FFBBBBBB" From="#88BBBBBB" Storyboard.TargetProperty="Background.Color" Duration="0:0:0.2" />
  32.                     </Storyboard>
  33.                 </BeginStoryboard>
  34.             </EventTrigger>
  35.             <EventTrigger RoutedEvent="MouseLeave">
  36.                 <BeginStoryboard>
  37.                     <Storyboard Storyboard.TargetProperty="Background.Color">
  38.                         <ColorAnimation To="#88BBBBBB" From="#FFBBBBBB" Storyboard.TargetProperty="Background.Color" Duration="0:0:0.2" />
  39.                     </Storyboard>
  40.                 </BeginStoryboard>
  41.             </EventTrigger>
  42.             <Trigger Property="IsEnabled" Value="False">
  43.                 <Setter Property="Opacity" Value="0.25" />
  44.                 <Setter Property="Cursor" Value="{x:Null}" />
  45.             </Trigger>
  46.             <Trigger Property="IsPressed" Value="True">
  47.                 <Setter Property="FontSize" Value="20pt" />
  48.             </Trigger>
  49.         </Style.Triggers>
  50.     </Style>
Advertisement
Add Comment
Please, Sign In to add comment