2011-10-25 87 views
0

我想,當鼠標進入按鈕,按鈕的字體變化的前景到另一種顏色如何動畫前景字體

我有這樣的風格對我的按鈕,但不工作動畫

<Style x:Key="StartButton" TargetType="{x:Type Button}"> 
     <Setter Property="Foreground" Value="{Binding solid1}"> 
      <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Button}" x:Name="Body"> 
        <Grid Name="Figure"> 
         <Grid.Resources> 
          <SolidColorBrush x:Key="solid1" x:Name="solid2" Color="Black"/> 
         </Grid.Resources> 
         . 
         . 
         . 
        </Grid> 
        <ControlTemplate.Triggers> 
        <EventTrigger RoutedEvent="Click"> 
        <BeginStoryboard> 
           <Storyboard Storyboard.TargetName="solid2" 
            Storyboard.TargetProperty="Color"> 
            <ColorAnimation From="Black" To="Red" 
            Duration="0:0:1"> 
            </ColorAnimation> 
           </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

感謝。

回答

0

而不是

Storyboard.TargetName="solid2" 

嘗試

Storyboard.Target="{StaticResource solid1}" 
+0

我要告你,因爲你使用暱稱的! – sergiol