Fork me on GitHub

一个按钮的资源文件(备用)

<Page.Resources>
  <ControlTemplate x:Key="ButtonControlTemplate1" TargetType="{x:Type Button}">
   <ControlTemplate.Resources>
    <Storyboard x:Key="Timeline1">
     <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
      <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
     </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="Timeline2">
     <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
      <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
     </DoubleAnimationUsingKeyFrames>
    </Storyboard>
   </ControlTemplate.Resources>
   <Border Width="Auto" Height="Auto" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
    <Border x:Name="border" Width="Auto" Height="Auto" Background="#7F000000" BorderBrush="#FF070707" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
     <Grid Width="Auto" Height="Auto">
      <Grid.RowDefinitions>
       <RowDefinition Height="0.5*"/>
       <RowDefinition Height="0.5*"/>
      </Grid.RowDefinitions>
      <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4">
       <Border.Background>
        <RadialGradientBrush>
         <RadialGradientBrush.RelativeTransform>
          <TransformGroup>
           <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.632" ScaleY="2.059"/>
           <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
           <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
           <TranslateTransform X="0.003" Y="0.529"/>
          </TransformGroup>
         </RadialGradientBrush.RelativeTransform>
         <GradientStop Color="#B2000000" Offset="0"/>
         <GradientStop Color="#008DBDFF" Offset="1"/>
        </RadialGradientBrush>
       </Border.Background>
      </Border>
      <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Grid.RowSpan="2"/>
      <Border Opacity="0" HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="glow" Width="Auto" Grid.RowSpan="1" CornerRadius="4,4,0,0">
       <Border.Background>
        <LinearGradientBrush EndPoint="0.5,0.979" StartPoint="0.5,0.042">
         <GradientStop Color="#99FFFFFF" Offset="0"/>
         <GradientStop Color="#33FFFFFF" Offset="1"/>
        </LinearGradientBrush>
       </Border.Background>
      </Border>
     </Grid>
    </Border>
   </Border>
   <ControlTemplate.Triggers>
    <Trigger Property="IsMouseOver" Value="True">
     <Trigger.EnterActions>
      <BeginStoryboard x:Name="Timeline1_BeginStoryboard" Storyboard="{StaticResource Timeline1}"/>
     </Trigger.EnterActions>
     <Trigger.ExitActions>
      <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/>
     </Trigger.ExitActions>
    </Trigger>
    <Trigger Property="IsPressed" Value="True">
     <Setter Property="Visibility" TargetName="glow" Value="Hidden"/>
     <Setter Property="Opacity" TargetName="shine" Value="0.4"/>
     <Setter Property="Background" TargetName="border" Value="#CC000000"/>
    </Trigger>
   </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="ButtonControlTemplate2" TargetType="{x:Type Button}">
   <ControlTemplate.Resources>
    <Storyboard x:Key="Timeline1">
     <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
      <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
     </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="Timeline2">
     <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
      <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
     </DoubleAnimationUsingKeyFrames>
    </Storyboard>
   </ControlTemplate.Resources>
   <Border Width="Auto" Height="Auto" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
    <Border x:Name="border" Width="Auto" Height="31.5" Background="#7F000000" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
     <Grid Width="Auto" Height="Auto">
      <Grid.RowDefinitions>
       <RowDefinition Height="0.492*"/>
       <RowDefinition Height="0.508*"/>
      </Grid.RowDefinitions>
      <Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2">
       <Border.Background>
        <RadialGradientBrush>
         <RadialGradientBrush.RelativeTransform>
          <TransformGroup>
           <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.545" ScaleY="2.032"/>
           <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
           <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
           <TranslateTransform X="0" Y="0.516"/>
          </TransformGroup>
         </RadialGradientBrush.RelativeTransform>
         <GradientStop Color="#CC4BE7F4" Offset="0"/>
         <GradientStop Color="#008DBDFF" Offset="1"/>
        </RadialGradientBrush>
       </Border.Background>
      </Border>
      <ContentPresenter HorizontalAlignment="Center" Margin="0,0,13.5,0" VerticalAlignment="Center" Grid.RowSpan="2"/>
      <Border Margin="0,0,0,0" x:Name="shine" VerticalAlignment="Stretch" Height="Auto" CornerRadius="4,4,0,0">
       <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1.068" StartPoint="0.5,0.138">
         <GradientStop Color="#99FFFFFF" Offset="0"/>
         <GradientStop Color="#33FFFFFF" Offset="0.99"/>
        </LinearGradientBrush>
       </Border.Background>
      </Border>
     </Grid>
    </Border>
   </Border>
   <ControlTemplate.Triggers>
    <Trigger Property="IsMouseOver" Value="True">
     <Trigger.EnterActions>
      <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
     </Trigger.EnterActions>
     <Trigger.ExitActions>
      <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/>
     </Trigger.ExitActions>
    </Trigger>
    <Trigger Property="IsPressed" Value="True">
     <Setter Property="Visibility" TargetName="glow" Value="Hidden"/>
     <Setter Property="Opacity" TargetName="shine" Value="0.4"/>
     <Setter Property="Background" TargetName="border" Value="#CC000000"/>
    </Trigger>
   </ControlTemplate.Triggers>
  </ControlTemplate>
 </Page.Resources>
posted @ 2007-03-28 11:58  桂素伟  阅读(393)  评论(0编辑  收藏  举报