日期:2014-05-17  浏览次数:21114 次

WPF,请问一个LayoutTransform变换的问题

<Grid >
    <Grid HorizontalAlignment="Left" Height="104" Margin="100,257,0,0" VerticalAlignment="Top" Width="714">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition />
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <Border Background="Black" Width="200" />
        <Border Grid.Column="1" Background="Red"/>
            <Border Grid.Column="2" Background="Black" Width="200" RenderTransformOrigin="0.5,0.5"/>
        </Grid>       
</Grid>




上面在Grid的三列中各放了一个Border,然后在Blend中,对第三个Border使用LayoutTransform属性应用变换,而不是使用RenderTransform属性。如下所示:


<Grid >
    <Grid HorizontalAlignment="Left" Height="104" Margin="100,257,0,0" VerticalAlignment="Top" Width="714">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition />
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <Border Background="Black" Width="200" />
        <Border Grid.Column="1" Background="Red"/>
        <Border Grid.Column="2" Background="Black" Width="200" RenderTransformOrigin="0.5,0.5">
            <Border.LayoutTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="30"/>
                    <TranslateTransform/>
                </TransformGroup>
            </Border.LayoutTransform>
        </Border>
    </Grid>       
</Grid>