2011-08-05 76 views
2

我有一個LinearGradientBrush用作OpacityMask,我希望我的動畫可以旋轉漸變,所以我嘗試對StartPoint和EndPoint的位置進行動畫製作,但無法使其工作幾個小時:(如何爲LinearGradient的StartPoint設置動畫

<Style x:Key="NewContentStyle" TargetType="ContentPresenter"> 
     <Setter Property="OpacityMask"> 
      <Setter.Value> 
       <LinearGradientBrush x:Name="FillGradient" EndPoint="0.5,1" StartPoint="0.5,0"> 
        <GradientStop Color="Black" Offset="0.5"/> 
        <GradientStop Color="Transparent" Offset="1"/> 
       </LinearGradientBrush> 
      </Setter.Value> 
     </Setter> 
    </Style> 

    <Storyboard x:Key="NewContentStoryboard"> 
     <PointAnimation Storyboard.TargetProperty="StartPoint" Storyboard.TargetName="FillGradient" From="0.5 0" To="0 0.5" Duration="00:00:1" /> 
     <PointAnimation Storyboard.TargetProperty="EndPoint" Storyboard.TargetName="FillGradient" From="1 0.5" To="0 0.5" Duration="00:00:1"/> 
    </Storyboard> 

我得到一個錯誤

回答

3

請試試這個「‘FillGradient’名稱不能以‘System.Windows.Controls.ContentPresenter’的名義範圍被發現。」:

<Storyboard x:Key="NewContentStoryboard"> 
    <PointAnimation Storyboard.TargetProperty="OpacityMask.(LinearGradientBrush.StartPoint)" From="0.5 0" To="0 0.5" Duration="00:00:1" /> 
    <PointAnimation Storyboard.TargetProperty="OpacityMask.(LinearGradientBrush.EndPoint)" From="1 0.5" To="0 0.5" Duration="00:00:1"/> 
</Storyboard> 
+0

此作品! :)我不知道有這樣的事情,「屬性路徑語法」:(非常感謝你! –