简体   繁体   English

UserControl with Bounding Box Scaling Point框

[英]UserControl with Bounding Box Scaling Point boxes

I want to make a UserControl like this image; 我想像这个图像一样制作一个UserControl ;

样品

There are 9 boxes, top one is for rotating, while other one is for scaling purposes. 有9个盒子,顶部用于旋转,而另一个用于缩放。 I tried to make this with grid and background image, 2 rows, and small boxes with StackPanel , but have to provide lots of negative and positive margins to achieve this result. 我尝试使用网格和背景图像,2行和StackPanel小方框来实现这一点,但必须提供大量的负边距和正边距才能实现此结果。 Is there any easy way to do so need help. 有没有简单的方法可以这样做需要帮助。

Thanks. 谢谢。

Something like this? 像这样的东西?

在此输入图像描述

<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
     <Grid.RowDefinitions>
         <RowDefinition Height="25"/>
         <RowDefinition Height="Auto"/>
     </Grid.RowDefinitions>
     <Grid.Resources>
         <Style TargetType="Rectangle">
             <Setter Property="Stroke" Value="Black"/>
             <Setter Property="StrokeThickness" Value="1"/>
             <Setter Property="Height" Value="11"/>
             <Setter Property="Width" Value="11"/>
             <!-- For hittestvisibility -->
             <Setter Property="Fill" Value="Transparent"/>
         </Style>
     </Grid.Resources>

     <Line X1="0" Y1="1" X2="0" Y2="0" Stretch="Fill" Stroke="Black" />
     <Rectangle VerticalAlignment="Top" HorizontalAlignment="Center"/>

     <Grid Grid.Row="1" Height="200" Width="200" Margin="-5">

         <Rectangle Margin="5" Height="Auto" Width="Auto" Fill="{x:Null}"/>
         <Rectangle VerticalAlignment="Top" HorizontalAlignment="Left"/>
         <Rectangle VerticalAlignment="Top" HorizontalAlignment="Center"/>
         <Rectangle VerticalAlignment="Top" HorizontalAlignment="Right"/>
         <Rectangle VerticalAlignment="Center" HorizontalAlignment="Left"/>
         <Rectangle VerticalAlignment="Center" HorizontalAlignment="Right"/>
         <Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
         <Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
         <Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Right"/>

         <!-- The Content -->
         <Rectangle Width="Auto" Height="Auto" Margin="20" Fill="Green"/>
         <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
                        Text="Content"/>
     </Grid>
</Grid>

The terminology is Bounding Box 术语是边界框

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

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