TranslateTransform 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
平移 (二维 x-y 坐标系中的对象) 移动。
public ref class TranslateTransform sealed : Transform
/// [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 TranslateTransform final : Transform
/// [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 TranslateTransform final : Transform
[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 TranslateTransform : Transform
[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 TranslateTransform : Transform
Public NotInheritable Class TranslateTransform
Inherits Transform
<TranslateTransform .../>
- 继承
- 属性
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
此示例使用 TranslateTransform 来偏移文本。 在本示例中,主要文本下方略微偏移的文本副本营造出了阴影效果。
<Canvas>
<!-- Offset the text using a TranslateTransform. -->
<TextBlock FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="Black"
Text="Translated Text">
<TextBlock.RenderTransform>
<TranslateTransform X="2" Y="2" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="Coral"
Text="Translated Text"/>
</Canvas>
<Canvas Width="200" Height="200">
<Rectangle PointerPressed="Rectangle_PointerPressed"
Width="50" Height="50"
Fill="RoyalBlue">
<Rectangle.RenderTransform>
<!-- If you give the transform a name
you can access it easily from code. -->
<TranslateTransform x:Name="myTranslateTransform" />
</Rectangle.RenderTransform>
</Rectangle>
</Canvas>
private void Rectangle_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
// Increase the X and Y properties.
myTranslateTransform.X = myTranslateTransform.X + 15;
myTranslateTransform.Y = myTranslateTransform.Y + 15;
}
构造函数
TranslateTransform() |
初始化 TranslateTransform 类的新实例。 |
属性
Dispatcher |
获取与此对象关联的 CoreDispatcher 。 CoreDispatcher 表示可以访问 UI 线程上的 DependencyObject 的工具,即使代码是由非 UI 线程启动的。 (继承自 DependencyObject) |
Inverse |
获取此 GeneralTransform 的反转换(如果可能)。 (继承自 GeneralTransform) |
InverseCore |
在派生的或自定义的 GeneralTransform 中实现 Inverse 的返回值的行为。 (继承自 GeneralTransform) |
X |
获取或设置沿 X 轴平移的距离。 |
XProperty |
标识 X 依赖属性。 |
Y |
获取或设置沿 Y 轴平移(移动)对象的距离。 |
YProperty |
标识 Y 依赖属性。 |