我有一个椭圆 如图所示。我需要在给定的Ellipse内绘制一个图元,如图所示。
XAML:
<Ellipse
Width="300"
Height="200"
Fill="Yellow"/>
图片:
更新: 如图所示,我具有用户控制。本质上,这是一个椭圆形的基础。另外,在给定的Ellipse中必须有一些图元。另外,我还需要通过Bindings分别隐藏/暴露那些基元。
主要问题是:只需尝试将UC放入MainWindow中,看看会发生什么。基本体将离开它们的坐标。另外,如果我增加/减小UC本身的大小,它将无法通过适当的方式进行缩放。
<UserControl
x:Class="Painting_test.UC_Ellipse"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Painting_test"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="300"
mc:Ignorable="d">
<Grid>
<Ellipse
Width="200"
Height="200"
Fill="Yellow"
Stroke="Black" />
<Path x:Name="Bridge"
Width="34.5"
Height="69.5"
Margin="115.5,127,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Data="M149,127 L115.5,195.5"
Fill=" Yellow"
Stretch="Fill"
Stroke="Black" />
<Path x:Name="Nose"
Width="38.5"
Height="1.008"
Margin="115.5,195.5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Data="M115.5,196.492 L153,196.5"
Fill=" Yellow"
Stretch="Fill"
Stroke="Black" />
<Rectangle x:Name="SquareEye"
Width="24"
Height="24"
Margin="103.984,118,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Fill="Yellow"
Stroke="Black" />
<Ellipse x:Name="CircleEye"
Width="24"
Height="24"
Margin="169,118,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Fill="Yellow"
Stroke="Black" />
</Grid>
</UserControl>