简体   繁体   English

在表格上放置旋转标签

[英]Placing rotated label on Form

I am having problems correctly placing my object, i want to achieve corner ribbon, something like this: 我在正确放置我的对象时遇到问题,我想实现边角功能区,如下所示:

在此处输入图片说明

Because my ribbon should be 1/5 of a whole form i devided form into 5 columns: 因为我的功能区应该是整个表格的1/5,所以我将表格分为5列:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid Grid.ColumnSpan="5">
    </Grid>
    <Border Margin="0" BorderThickness="2" Height="auto" BorderBrush="White" Background="#FFE12727" HorizontalAlignment="Stretch" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" Padding="0,0,6,0">
        <Border.RenderTransform>
            <CompositeTransform Rotation="-45"/>
        </Border.RenderTransform>
        <Viewbox VerticalAlignment="Center" Margin="50,15,50,10">
            <TextBlock VerticalAlignment="Center" Text="NEW HERE?"/>
        </Viewbox>
    </Border>
</Grid>

It looks like this: 看起来像这样:

在此处输入图片说明

How should i set the margins, padding etc, so that ribbon on all resolutions remained like on 1 picture? 我应该如何设置页边距,填充等,以使所有分辨率上的色带都像一张图片一样?

Or any different way to achieve this? 或任何其他方式来实现这一目标?

You can use the CenterX and CenterY properties to set the center of rotation for the object. 您可以使用CenterX和CenterY属性来设置对象的旋转中心。 In your case the rotation center is in the middle of the border - playing a bit with these properties and it should work 在您的情况下,旋转中心位于边框的中间-使用这些属性可以发挥一些作用,它应该可以工作

For example, if you wanted a 100 by 100 square to pivot around its center, you would set the CenterX and CenterY properties to 50. 例如,如果您希望一个100 x 100的正方形围绕其中心旋转,则可以将CenterX和CenterY属性设置为50。

by http://msdn.microsoft.com/en-us/library/system.windows.media.compositetransform.rotation(v=vs.95).aspx 通过http://msdn.microsoft.com/zh-cn/library/system.windows.media.compositetransform.rotation(v=vs.95).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM