Timeline.SpeedRatio 屬性

定義

取得或設定這個 Timeline 相對於其父代的時間進行比率。

public:
 property double SpeedRatio { double get(); void set(double value); };
public double SpeedRatio { get; set; }
member this.SpeedRatio : double with get, set
Public Property SpeedRatio As Double

屬性值

Double

一個大於 0 的有限值,說明這個時刻表相對於其父代之速度的時間進行比率,而如果這是根時刻表,則為預設時刻表速度。 預設值為 1。

例外狀況

SpeedRatio 小於 0 或不是有限值。

範例

時間軸 SpeedRatio 的 屬性會控制相對於其父系的進度速率。 如果時程表是根目錄,則其 SpeedRatio 相對於預設時程表速度。 下列範例顯示具有不同 SpeedRatio 設定的數個時程表。

<!-- This example shows how to use the SpeedRatio property 
     to make animations speed up or slow down. -->
<Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  WindowTitle="Speed Example">
  <StackPanel>

    <!-- The rectangles to animate. -->          
    <Rectangle Name="DefaultSpeedRectangle" 
      Width="20" Height="20" Fill="Blue"  />      
    <Rectangle Name="FasterRectangle" 
      Width="20" Height="20" Fill="Blue" />      
    <Rectangle Name="SlowerRectangle" 
      Width="20" Height="20" Fill="Blue" />
    <Rectangle Name="NestedTimelinesExampleRectangle" 
      Width="20" Height="20" Fill="Blue" />      
    
    <!-- Create a button to start the animations. -->
    <Button Margin="0,30,0,0" HorizontalAlignment="Left">Start Animations
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>

              <!-- This animation progresses at the same rate as its parent. -->
              <DoubleAnimation 
                Storyboard.TargetName="DefaultSpeedRectangle" 
                Storyboard.TargetProperty="Width" 
                From="20" To="400" Duration="0:0:2" 
                SpeedRatio="1" />

              <!-- This animation progresses twice as fast as its parent. -->
              <DoubleAnimation 
                Storyboard.TargetName="FasterRectangle" 
                Storyboard.TargetProperty="Width"
                From="20" To="400" Duration="0:0:2" 
                SpeedRatio="2"  />   

              <!-- This animation progresses at half the rate of its parent. -->
              <DoubleAnimation 
                Storyboard.TargetName="SlowerRectangle" 
                Storyboard.TargetProperty="Width" 
                From="20" To="400" Duration="0:0:2" 
                SpeedRatio="0.5"  />    
                

              <ParallelTimeline SpeedRatio="2">
                <ParallelTimeline SpeedRatio="2">
                
                  <!-- This animation progresses eight times faster
                       than normal, because of its SpeedRatio settings
                       and the SpeedRatio settings on its parents. -->
                  <DoubleAnimation 
                    Storyboard.TargetName="NestedTimelinesExampleRectangle" 
                    Storyboard.TargetProperty="Width" 
                    From="20" To="400" Duration="0:0:2" 
                    SpeedRatio="2"  />  
                </ParallelTimeline>
              </ParallelTimeline>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>     
    </Button>
  </StackPanel>
</Page>

備註

時間軸的 SpeedRatio 設定不會影響其 BeginTime ;該時間相對於時間軸的父系,或者,如果時程表是根時程表,則時間軸開始的時間點。

如果 AccelerationRatio 指定 或 DecelerationRatio ,這是 SpeedRatio 時間軸自然長度的平均比率。

相依性屬性資訊

識別碼欄位 SpeedRatioProperty
設定為 的中繼資料屬性 true

適用於