0

我有两个矩形和一个椭圆。如何组合它们并在新的组合元素上使用相同的动画?

<Rectangle Height="100" HorizontalAlignment="Left" Margin="220,235,0,0" Name="rectangle2" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="38" Fill="LightGreen" />
<Ellipse Height="23" HorizontalAlignment="Left" Margin="227,269,0,0" Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="24" Fill="Yellow" />
<Ellipse Height="17" HorizontalAlignment="Left" Margin="12,266,0,0" Name="ellipse2" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="17" Fill="#FF58FF00" />
4

2 回答 2

1

如果您想要固定大小的元素,相对于彼此移动,然后将它们放在画布中并使用画布坐标来定位它们。

画布的渲染开销很低,因为它只显示其子元素(以像素偏移量表示),并且没有复杂的边距或行计算。

相当于你的例子是:

    <Canvas HorizontalAlignment="Left" Margin="12,235,0,145" Width="246">
        <Rectangle Height="100" x:Name="rectangle2" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="38" Fill="LightGreen" Canvas.Left="208" />
        <Ellipse Height="23" x:Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="24" Fill="Yellow" Canvas.Left="215" Canvas.Top="34" />
        <Ellipse Height="17" x:Name="ellipse2" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="17" Fill="#FF58FF00" Canvas.Top="31" />
    </Canvas>
于 2012-05-19T21:02:42.613 回答
0

分组到 T:Panel。通常我首先在 Canvas 中进行分组,然后在 Viewbox (Fill ot Fit) 中进行分组。

于 2012-05-19T20:42:19.380 回答