SplitOpenThemeAnimation 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示使用 分割 動畫顯示目標 UI 的預先設定動畫。
public ref class SplitOpenThemeAnimation sealed : Timeline
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class SplitOpenThemeAnimation final : Timeline
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class SplitOpenThemeAnimation final : Timeline
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class SplitOpenThemeAnimation : Timeline
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class SplitOpenThemeAnimation : Timeline
Public NotInheritable Class SplitOpenThemeAnimation
Inherits Timeline
<SplitOpenThemeAnimation .../>
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10 (已於 10.0.10240.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
|
範例
以下是使用分割開啟和分割關閉主題動畫的自訂控制項範例。
// Themes/Generic.xaml
<!-- Example template of a custom control that uses split open
and split close theme animations. -->
<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:SplitOpenControl" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SplitOpenControl">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OpenStates">
<VisualState x:Name="Open">
<Storyboard>
<SplitOpenThemeAnimation
OpenedTargetName="contentBorder"
ContentTargetName="content"
ClosedTargetName="targetRect"
ContentTranslationDirection="Left"
ContentTranslationOffset="200"
OffsetFromCenter="0"
OpenedLength="200"
ClosedLength="0"/>
<DoubleAnimation
Storyboard.TargetName="targetRect"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Closed">
<Storyboard>
<SplitCloseThemeAnimation
OpenedTargetName="contentBorder"
ContentTargetName="content"
ClosedTargetName="targetRect"
ContentTranslationDirection="Left"
ContentTranslationOffset="-200"
OffsetFromCenter="0"
OpenedLength="200"
ClosedLength="0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="targetRect" Width="100" Height="100" Fill="Blue"/>
<Popup IsOpen="False" Height="50" Width="200" x:Name="contentPopup">
<Border x:Name="contentBorder" BorderBrush="Orange" BorderThickness="3">
<TextBlock x:Name="content" Text="Hello, World!" FontSize="20"/>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
public sealed class SplitOpenControl : Control
{
private Popup _contentPopup;
public SplitOpenControl()
{
this.DefaultStyleKey = typeof(SplitOpenControl);
}
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
_contentPopup = GetTemplateChild("contentPopup") as Popup;
}
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
this.CapturePointer(e.Pointer);
_contentPopup.IsOpen = true;
VisualStateManager.GoToState(this, "Open", true);
}
protected override void OnPointerReleased(PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "Closed", true);
this.ReleasePointerCapture(e.Pointer);
}
}
// SplitOpenControl.h:
struct SplitOpenControl : SplitOpenControlT<SplitOpenControl>
{
SplitOpenControl(){ DefaultStyleKey(winrt::box_value(L"MyApp.SplitOpenControl")); }
void OnApplyTemplate();
void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
private:
Windows::UI::Xaml::Controls::Primitives::Popup m_contentPopup;
};
// SplitOpenControl.cpp:
void SplitOpenControl::OnApplyTemplate()
{
m_contentPopup = GetTemplateChild(L"contentPopup").as<Windows::UI::Xaml::Controls::Primitives::Popup>();
}
void SplitOpenControl::OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
CapturePointer(e.Pointer());
m_contentPopup.IsOpen(true);
Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"Open", true);
}
void SplitOpenControl::OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"Closed", true);
ReleasePointerCapture(e.Pointer());
}
// SplitOpenControl.h:
public ref class SplitOpenControl sealed : public Windows::UI::Xaml::Controls::Control
{
public:
SplitOpenControl();
protected:
virtual void OnApplyTemplate() override;
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
virtual void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
private:
Windows::UI::Xaml::Controls::Primitives::Popup ^m_contentPopup;
};
// SplitOpenControl.cpp:
SplitOpenControl::SplitOpenControl()
{
DefaultStyleKey = "MyApp.SplitOpenControl";
}
void SplitOpenControl::OnApplyTemplate()
{
m_contentPopup = static_cast<Popup^>(GetTemplateChild("contentPopup"));
}
void SplitOpenControl::OnPointerPressed(PointerRoutedEventArgs^ e)
{
CapturePointer(e->Pointer);
m_contentPopup->IsOpen = true;
VisualStateManager::GoToState(this, "Open", true);
}
void SplitOpenControl::OnPointerReleased(PointerRoutedEventArgs^ e)
{
VisualStateManager::GoToState(this, "Closed", true);
ReleasePointerCapture(e->Pointer);
}
備註
請注意,設定 Duration 屬性不會影響此物件,因為預先設定持續時間。
建構函式
SplitOpenThemeAnimation() |
初始化 SplitOpenThemeAnimation 類別的新實例。 |
屬性
方法
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) |
事件
Completed |
發生于 Storyboard 物件已完成播放時。 (繼承來源 Timeline) |