Timeline.AllowDependentAnimations 屬性

定義

取得或設定值,這個值會決定是否應該在整個應用程式中執行相依動畫。

public:
 static property bool AllowDependentAnimations { bool get(); void set(bool value); };
static bool AllowDependentAnimations();

static void AllowDependentAnimations(bool value);
public static bool AllowDependentAnimations { get; set; }
var boolean = Timeline.allowDependentAnimations;
Timeline.allowDependentAnimations = boolean;
Public Shared Property AllowDependentAnimations As Boolean

屬性值

Boolean

bool

如果動畫可以在應用程式中針對相依動畫案例執行,則為true。 否則為 false。 預設值為 True

備註

如果您想要將此屬性值設定為 false,請在頁面或應用程式初始化過程中執行此動作,例如在應用程式啟用處理常式中。 屬性是應用程式的全域屬性,而且就像應用程式設定一樣,即使您在頁面範圍中設定它也一樣。

AllowDependentAnimations 的 false 值會覆寫個別動畫上 EnableDependentAnimation 設定為 true 的所有案例。 當 AllowDependentAnimations 為 false時,您的應用程式中不會執行任何相依動畫,它們全都如同 EnableDependentAnimation 在所有動畫上都是 false 。 對於在應用程式頁面 XAML 中宣告的動畫,可能似乎不需要停用相依動畫,因為您已透過明確設定 EnableDependentAnimation 屬性來控制這些動畫。 但 AllowDependentAnimations 的案例更適用于使用控制項範本的控制項作者,這些控制項範本可能包含相依動畫。 如果控制項作者未遵循視覺狀態最佳做法,這類動畫可能存在於視覺狀態中。 (預設Windows 執行階段控制項的控制項範本沒有相依的動畫,因此,如果您只使用預設 XAML 控制項和預設範本,則不需要使用 AllowDependentAnimations。)

注意

如果您使用 UIElement.CacheMode,您可能不小心建立相依動畫,即使使用預設 XAML 控制項也一樣;如需詳細資訊,請參閱 UIElement.CacheMode和優化動畫和媒體

適用於

另請參閱