EntranceThemeTransition 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供控件首次出现时的动画过渡行为。 可以在单个对象或对象的容器上使用此功能。 在后一种情况下,子元素将按顺序(而不是同时全部)动画到视图中。
public ref class EntranceThemeTransition 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 EntranceThemeTransition 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 EntranceThemeTransition 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 EntranceThemeTransition : 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 EntranceThemeTransition : Transition
Public NotInheritable Class EntranceThemeTransition
Inherits Transition
<EntranceThemeTransition .../>
- 继承
- 属性
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
此示例演示如何将 EntranceThemeTransition 应用于 Button。
<Button Content="EntranceThemeTransition Button">
<Button.Transitions>
<TransitionCollection>
<!-- This transition just uses the default behavior which is to
have the button animate into view from the right. You can
make it start from anywhere on the right by using the
FromHorizontalOffset property. If you'd rather see a vertical
animation, use the FromVerticalOffset property. -->
<EntranceThemeTransition />
</TransitionCollection>
</Button.Transitions>
</Button>
在这里,使用 Style 资源应用 EntranceThemeTransition。
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<Grid.Resources>
<Style x:Key="DefaultButtonStyle" TargetType="Button">
<Setter Property="Transitions">
<Setter.Value>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Button Style="{StaticResource DefaultButtonStyle}"
Content="EntranceThemeTransition style applied" />
</Grid>
如果在面板上设置 EntranceThemeTransition 动画,则面板的子级在动画进入视图中时会自动偏移,以创建具有视觉吸引力的入口。
在这里,当矩形添加到 StackPanel 时,它们从右上角飞入,而不仅仅是就地显示。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Add rectangle" Click="Button_Click"/>
<StackPanel x:Name="panel1" HorizontalAlignment="Left" Margin="200">
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition
FromHorizontalOffset="200"
FromVerticalOffset="-200"/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
</StackPanel>
</Grid>
private void Button_Click(object sender, RoutedEventArgs e)
{
// Add a rectangle to the StackPanel.
Rectangle r = new Rectangle();
r.Width = 100;
r.Height = 100;
// Alternate colors as rectangles are added.
if (panel1.Children.Count % 2 == 0)
{
r.Fill = new SolidColorBrush(Colors.Green);
}
else
{
r.Fill = new SolidColorBrush(Colors.Yellow);
}
panel1.Children.Add(r);
}
构造函数
EntranceThemeTransition() |
初始化 EntranceThemeTransition 类的新实例。 |
属性
Dispatcher |
获取与此对象关联的 CoreDispatcher 。 CoreDispatcher 表示可以访问 UI 线程上的 DependencyObject 的工具,即使代码是由非 UI 线程启动的。 (继承自 DependencyObject) |
FromHorizontalOffset |
获取或设置动画处于活动状态时目标在水平方向上平移的距离。 |
FromHorizontalOffsetProperty |
标识 FromHorizontalOffset 依赖属性。 |
FromVerticalOffset |
获取或设置动画处于活动状态时目标在垂直方向上转换的距离。 |
FromVerticalOffsetProperty |
标识 FromVerticalOffset 依赖属性。 |
IsStaggeringEnabled |
获取或设置一个值,该值确定过渡是呈现多个项,还是一次呈现所有项。 |
IsStaggeringEnabledProperty |
标识 IsStaggeringEnabled 依赖属性。 |
方法
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) |