DragItemThemeAnimation 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示應用於被拖曳之項目元素的預先配置動畫。
public ref class DragItemThemeAnimation sealed : Timeline
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DragItemThemeAnimation final : Timeline
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DragItemThemeAnimation : Timeline
Public NotInheritable Class DragItemThemeAnimation
Inherits Timeline
<DragItemThemeAnimation .../>
- 繼承
- 屬性
範例
以下是一個可拖曳的自訂控制範例。
// Themes/Generic.xaml
<!-- Example template of a drag-enabled custom control. The
DragItemThemeAnimation will be run when the control
is in the Dragging state, and reverted when it isn't.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BlankApp1">
<Style TargetType="local:DraggableControl" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:DraggableControl">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="DragStates">
<VisualState x:Name="NotDragging"/>
<VisualState x:Name="Dragging">
<Storyboard>
<DragItemThemeAnimation TargetName="contentRectangle"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="contentRectangle" Width="100" Height="100" Fill="{TemplateBinding Background}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
public sealed class DraggableControl : Control
{
public DraggableControl()
{
this.DefaultStyleKey = typeof(DraggableControl);
}
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
// Go to the Dragging state, which will start the DragItemThemeAnimation.
VisualStateManager.GoToState(this, "Dragging", true);
}
protected override void OnPointerReleased(PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "NotDragging", true);
}
protected override void OnPointerMoved(PointerRoutedEventArgs e)
{
// dragging implementation here.
}
}
// DraggableControl.h
struct DraggableControl : DraggableControlT<DraggableControl>
{
DraggableControl(){ DefaultStyleKey(winrt::box_value(L"MyApp.DraggableControl")); }
void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
void OnPointerMoved(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
};
// DraggableControl.cpp
void DraggableControl::OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
// Go to the Dragging state, which will start the DragItemThemeAnimation.
Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"Dragging", true);
}
void DraggableControl::OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"NotDragging", true);
}
void DraggableControl::OnPointerMoved(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
// dragging implementation here.
}
// DraggableControl.h:
public ref class DraggableControl sealed : public Windows::UI::Xaml::Controls::Control
{
public:
DraggableControl();
protected:
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
virtual void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
virtual void OnPointerMoved(Windows::UI::Xaml::Input:: PointerRoutedEventArgs^ e) override;
};
// DraggableControl.cpp:
DraggableControl::DraggableControl()
{
DefaultStyleKey = "MyApp.DraggableControl";
}
void DraggableControl::OnPointerPressed(PointerRoutedEventArgs^ e)
{
// Go to the Dragging state, which will start the DragItemThemeAnimation
VisualStateManager::GoToState(this, "Dragging", true);
}
void DraggableControl::OnPointerReleased(PointerRoutedEventArgs^ e)
{
VisualStateManager::GoToState(this, "NotDragging", true);
}
void DraggableControl::OnPointerMoved(PointerRoutedEventArgs^ e)
{
// dragging implementation here
}
備註
請注意,設定持續 時間 屬性對此物件沒有影響,因為持續時間是預先設定好的。
建構函式
| 名稱 | Description |
|---|---|
| DragItemThemeAnimation() |
初始化一個新的 DragItemThemeAnimation 類別實例。 |
屬性
| 名稱 | Description |
|---|---|
| AutoReverse |
取得或設定一個值,指示時間軸在完成正向迭代後是否會反向播放。 (繼承來源 Timeline) |
| BeginTime |
取得或設定此 時間軸 應開始的時間。 (繼承來源 Timeline) |
| Dispatcher |
它總是在 Windows 應用程式 SDK 應用程式中回傳 |
| DispatcherQueue |
得到 |
| Duration |
取得或設定此時間軸播放的時間長度,不計重複次數。 (繼承來源 Timeline) |
| FillBehavior |
取得或設定一個值,指定動畫在達到有效期間結束後的行為。 (繼承來源 Timeline) |
| RepeatBehavior |
他會觸發或設定這個時間線重複的行為。 (繼承來源 Timeline) |
| SpeedRatio |
取得或設定相對於父節點的速率,該 時間軸中時間的進展。 (繼承來源 Timeline) |
| TargetName |
取得或設定被鎖定控制元件的參考名稱。 |
| TargetNameProperty |
識別 TargetName 相依屬性。 |
方法
| 名稱 | Description |
|---|---|
| ClearValue(DependencyProperty) |
清除依賴性財產的局部價值。 (繼承來源 DependencyObject) |
| GetAnimationBaseValue(DependencyProperty) |
回傳任何為相依屬性建立的基礎值,適用於動畫未啟用時。 (繼承來源 DependencyObject) |
| GetValue(DependencyProperty) |
回傳 DependencyObject 中相依屬性的當前有效值。 (繼承來源 DependencyObject) |
| ReadLocalValue(DependencyProperty) |
若設定了本地值,則回傳依賴性質的局部值。 (繼承來源 DependencyObject) |
| RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback) |
註冊一個通知函式,用於監聽此 DependencyObject 實例中特定 DependencyProperty 的變更。 (繼承來源 DependencyObject) |
| SetValue(DependencyProperty, Object) |
將相依屬性的局部值設定在 DependencyObject 上。 (繼承來源 DependencyObject) |
| UnregisterPropertyChangedCallback(DependencyProperty, Int64) |
取消先前透過呼叫 RegisterPropertyChangedCallback 註冊的變更通知。 (繼承來源 DependencyObject) |
事件
| 名稱 | Description |
|---|---|
| Completed |
當 分鏡 物件完成播放時會發生。 (繼承來源 Timeline) |