SplitOpenThemeAnimation 类

定义

表示使用 拆分 动画显示目标 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 .../>
继承
Object Platform::Object IInspectable DependencyObject 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 类的新实例。

属性

AutoReverse

获取或设置一个值,该值指示时间线在完成向前迭代后是否按相反的顺序播放。

(继承自 Timeline)
BeginTime

获取或设置此 时间线 应开始的时间。

(继承自 Timeline)
ClosedLength

获取或设置动画方向上目标元素的初始大小。

ClosedLengthProperty

标识 ClosedLength 依赖属性。

ClosedTarget

获取或设置指定初始剪辑大小的 UI 元素。

ClosedTargetName

获取或设置指定初始剪辑大小的 UI 元素的标识名称。

ClosedTargetNameProperty

标识 ClosedTargetName 依赖属性。

ClosedTargetProperty

标识 ClosedTarget 依赖属性。

ContentTarget

获取或设置将转换的 UI 元素。 通常,这是 由 OpenedTargetName 或 OpenedTarget 标识 的元素的子/部分。

ContentTargetName

获取或设置将转换的 UI 元素的标识名称。 通常,这是 OpenedTargetName 标识的元素的子/部分。

ContentTargetNameProperty

标识 ContentTargetName 依赖属性。

ContentTargetProperty

标识 ContentTarget 依赖属性。

ContentTranslationDirection

获取或设置一个值,该值确定动画运行时内容应转换的方向。

ContentTranslationDirectionProperty

标识 ContentTranslationDirection 依赖属性。

ContentTranslationOffset

获取或设置在动画运行时要转换的像素。

ContentTranslationOffsetProperty

标识 ContentTranslationOffset 依赖属性。

Dispatcher

获取与此对象关联的 CoreDispatcherCoreDispatcher 表示可以访问 UI 线程上的 DependencyObject 的工具,即使代码是由非 UI 线程启动的。

(继承自 DependencyObject)
Duration

获取或设置此时间线播放的时间长度,而不是计数重复。

(继承自 Timeline)
FillBehavior

获取或设置一个值,该值指定动画在其活动周期结束时的行为方式。

(继承自 Timeline)
OffsetFromCenter

获取或设置与 打开 的目标中心的偏移量。

OffsetFromCenterProperty

标识 OffsetFromCenter 依赖属性。

OpenedLength

获取或设置目标 UI 元素的最终大小。

OpenedLengthProperty

标识 OpenedLength 依赖属性。

OpenedTarget

获取或设置将剪裁的 UI 元素。

OpenedTargetName

获取或设置要剪裁的 UI 元素的标识名称。

OpenedTargetNameProperty

标识 OpenedTargetName 依赖属性。

OpenedTargetProperty

标识 OpenedTarget 依赖属性。

RepeatBehavior

获取或设置此时间线的重复行为。

(继承自 Timeline)
SpeedRatio

获取或设置相对于其父级的速率,此时此 时间线的进度。

(继承自 Timeline)

方法

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)

适用于

另请参阅