WPF RenderTransform的使用

呈现变形的元素并没有改变位置,只是呈现在不同的位置而已,所以动画要用呈现变形

好处:为了效率,如果改变位置的话,需要重新测量,布局

<Window x:Class="wpf180709.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="509.067" Width="569.776">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Button Width="80" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Hello">
            <Button.RenderTransform>
                <TransformGroup>
                    <RotateTransform CenterX="40" CenterY="40" Angle="45"></RotateTransform>
                    <TranslateTransform X="300" Y="300"></TranslateTransform>
                </TransformGroup>
            </Button.RenderTransform>

        </Button>
    </Grid>
</Window>
原文地址:https://www.cnblogs.com/dxmfans/p/9434609.html