语言

SplitOpenThemeAnimation 类

定义

表示预配置动画,该动画使用 拆分 动画显示目标 UI。

public ref class SplitOpenThemeAnimation 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 SplitOpenThemeAnimation 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 SplitOpenThemeAnimation : Timeline
Public NotInheritable Class SplitOpenThemeAnimation
Inherits Timeline
<SplitOpenThemeAnimation .../>
继承
Object Platform::Object IInspectable DependencyObject Timeline SplitOpenThemeAnimation
属性

示例

下面是使用拆分打开和拆分关闭主题动画的自定义控件的示例。

// 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

始终在 Windows 应用 SDK 应用中返回 null 。 请改用 DispatcherQueue 。

(继承自 DependencyObject)
DispatcherQueue

获取 DispatcherQueue 与此对象关联的对象。 表示 DispatcherQueue 即使代码是由非 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

情节提要对象已完成播放时发生。

(继承自 Timeline)

适用于

另请参阅