WPF/位置转换 [英] WPF/ Position Transform

查看:92
本文介绍了WPF/位置转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

有没有简单的方法可以将 Position 变换添加到元素?具体来说,我被RotateTransform迷住了

例如:

Hello,

Is there any simple way to add a Position transform to an element? Specifically, I am intrested in a RotateTransform

E.g.:

before:
|
x
|
a

after 180 degree rotate transform performed on letter ''a'' with a center at point x:
a
|
x
|

NOT:
(rotated ''a'')
|
x
|


知道了吗?

预先感谢,

问候-Jacek


Got it?

Thanks in advance,

Greetings - Jacek

推荐答案

如何处理:

How about this:

<Window x:Class="Transform.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Label Content="A" Height="48" HorizontalAlignment="Left" Margin="134,124,0,0" Name="label1" VerticalAlignment="Top" Width="41" FontWeight="Bold" FontSize="32">
            <Label.RenderTransform>
                <RotateTransform Angle="-45" CenterX="-50" CenterY="-50" />
            </Label.RenderTransform>
        </Label>
    </Grid>
</Window>



只需此XAML.我已将字母放入标签中,但这也适用于任何其他文本,甚至适用于其他控件.

您不能直接在字母或字符串上使用转换,但可以在包含它们的控件上使用转换.



This XAML is all that is needed. I have put the letter into a label, but this would also work with any other text and even with other controls.

You can''t use transformations on a letter or a string directly, but you can use the transformation on the controls containing them.


这篇关于WPF/位置转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆