ContentThemeTransition 类

定义

为控件的内容发生更改的情况提供动画过渡表现方式。 除了 AddDeleteThemeTransition 之外,可能还会应用此内容。

public ref class ContentThemeTransition sealed : Transition
/// [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 ContentThemeTransition final : Transition
/// [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 ContentThemeTransition final : Transition
[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 ContentThemeTransition : Transition
[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 ContentThemeTransition : Transition
Public NotInheritable Class ContentThemeTransition
Inherits Transition
<ContentThemeTransition ... />
继承
Object Platform::Object IInspectable DependencyObject Transition ContentThemeTransition
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例将 ContentThemeAnimation 应用于矩形。

<!-- The ContentThemeTransition will execute when the ContentControl’s content changes. -->        
<ContentControl x:Name="ContentHost" PointerPressed="ContentHost_PointerPressed">
    <ContentControl.ContentTransitions>
        <TransitionCollection>
            <ContentThemeTransition/>
        </TransitionCollection>
    </ContentControl.ContentTransitions>
    <Rectangle Height="200" Width="200" Fill="Orange"/>
</ContentControl>
private void ContentHost_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    // Replace the ContentControl's content with a new Rectangle of a random color.
    Rectangle newItem = new Rectangle();
    Random rand = new Random();

    newItem.Height = 200;
    newItem.Width = 200;
    newItem.Fill = new SolidColorBrush(Color.FromArgb(255, 
         (byte)rand.Next(0, 255), (byte)rand.Next(0,255), (byte)rand.Next(0, 255)));

    ContentHost.Content = newItem; 
}
void ContentHost_PointerPressed(Windows::Foundation::IInspectable const& /* sender */,
    Windows::UI::Xaml::Input::PointerRoutedEventArgs const& /* e */)
{
    // Replace the ContentControl's content with a new Rectangle of a random color.
    Windows::UI::Xaml::Shapes::Rectangle newItem;

    newItem.Height(200);
    newItem.Width(200);

    Windows::UI::Color color;
    color.R = std::rand() % 256;
    color.G = std::rand() % 256;
    color.B = std::rand() % 256;

    newItem.Fill(Windows::UI::Xaml::Media::SolidColorBrush{ color });

    ContentHost().Content(newItem);
}
void MyPage::ContentHost_PointerPressed(Object^ sender, PointerRoutedEventArgs^ e)
{
    // Replace the ContentControl's content with a new Rectangle of a random color.
    Rectangle^ newItem = ref new Rectangle();

    newItem->Height = 200;
    newItem->Width = 200;

    Color color;
    color.R = rand() % 256;
    color.G = rand() % 256;
    color.B = rand() % 256;

    newItem->Fill = ref new SolidColorBrush(color);

    ContentHost->Content = newItem; 
}

注解

请注意,设置 Duration 属性不会影响此对象,因为持续时间是预配置的。

构造函数

ContentThemeTransition()

初始化 ContentThemeTransition 类的新实例。

属性

Dispatcher

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

(继承自 DependencyObject)
HorizontalOffset

获取或设置转换处于活动状态时目标在水平方向上平移的距离。

HorizontalOffsetProperty

标识 HorizontalOffset 依赖属性。

VerticalOffset

获取或设置转换处于活动状态时目标在垂直方向上平移的距离。

VerticalOffsetProperty

标识 VerticalOffset 依赖属性。

方法

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)

适用于

另请参阅