ScaleTransform 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
縮放二維 x-y 座標系統中的物件。
public ref class ScaleTransform 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 ScaleTransform 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 ScaleTransform 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 ScaleTransform : 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 ScaleTransform : Transform
Public NotInheritable Class ScaleTransform
Inherits Transform
<ScaleTransform .../>
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10 (已於 10.0.10240.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
|
範例
這個 XAML 範例會使用 ScaleTransform 從原始大小調整文字。
<StackPanel>
<TextBlock FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text" />
<!-- Scale the text width using a ScaleTransform. -->
<TextBlock FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.0" />
</TextBlock.RenderTransform>
</TextBlock>
<!-- Scale the text height using a ScaleTransform. -->
<TextBlock FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="1.0" ScaleY="2.0" />
</TextBlock.RenderTransform>
</TextBlock>
</StackPanel>
套用轉換之後,文字看起來像這樣:
此範例示範如何在執行時間存取和修改程式碼中的轉換。 每次按下矩形時,縮放比例就會增加。
<StackPanel>
<Rectangle PointerPressed="HandlePointerPressed"
Width="50" Height="50" Fill="RoyalBlue">
<Rectangle.RenderTransform>
<!-- If you give the transform a name you can
access it easily from code. -->
<ScaleTransform x:Name="myScaleTransform" />
</Rectangle.RenderTransform>
</Rectangle>
</StackPanel>
private void HandlePointerPressed(object sender, PointerRoutedEventArgs e)
{
// Increase ScaleX and ScaleY by 25%.
myScaleTransform.ScaleX = myScaleTransform.ScaleX * 1.25;
myScaleTransform.ScaleY = myScaleTransform.ScaleY * 1.25;
}
Private Sub HandlePointerPressed(ByVal sender As Object, ByVal e As PointerRoutedEventArgs)
' Increase ScaleX and ScaleY by 25%.
myScaleTransform.ScaleX = (myScaleTransform.ScaleX * 1.25)
myScaleTransform.ScaleY = (myScaleTransform.ScaleY * 1.25)
End Sub
建構函式
ScaleTransform() |
初始化 ScaleTransform 類別的新實例。 |
屬性
CenterX |
取得或設定這個 ScaleTransform中心點的 X 座標。 |
CenterXProperty |
識別 CenterX 相依性屬性。 |
CenterY |
取得或設定這個 ScaleTransform中心點的 Y 座標。 |
CenterYProperty |
識別 CenterY 相 依性屬性。 |
Dispatcher |
取得與此物件相關聯的 CoreDispatcher 。 CoreDispatcher代表可以存取 UI 執行緒上DependencyObject的功能,即使程式碼是由非 UI 執行緒起始也一樣。 (繼承來源 DependencyObject) |
Inverse |
如果可能,取得這個 GeneralTransform的反向轉換。 (繼承來源 GeneralTransform) |
InverseCore |
在衍生或自訂GeneralTransform中實作Inverse傳回值的行為。 (繼承來源 GeneralTransform) |
ScaleX |
取得或設定 X 軸縮放比例。 |
ScaleXProperty |
識別 ScaleX 相依性屬性。 |
ScaleY |
取得或設定 Y 軸縮放比例。 |
ScaleYProperty |
識別 ScaleY 相依性屬性。 |