日期:2014-05-18 浏览次数:20897 次
<Canvas xmlns:local="clr-namespace:WPFTester">
<Canvas.Resources>
<Style TargetType="Ellipse">
<Setter Property="Width" Value="{x:Static local:PointsConverter.PointWidth}" />
<Setter Property="Height" Value="{x:Static local:PointsConverter.PointWidth}" />
<Setter Property="Cursor" Value="SizeAll" />
<Setter Property="Fill" Value="Blue" />
<EventSetter Event="MouseLeftButtonDown" Handler="Element_MouseLeftButtonDown" />
<EventSetter Event="MouseMove" Handler="Element_MouseMove" />
<EventSetter Event="MouseLeftButtonUp" Handler="Element_MouseLeftButtonUp" />
</Style>
<local:PointsConverter x:Key="PointsConverter" />
</Canvas.Resources>
<Polygon Fill="Red">
<Polygon.Points>
<MultiBinding Mode="TwoWay" Converter="{StaticResource PointsConverter}">
<Binding ElementName="P1" Path="(Canvas.Left)" />
<Binding ElementName="P1" Path="(Canvas.Top)" />
<Binding ElementName="P2" Path="(Canvas.Left)" />
<Binding ElementName="P2" Path="(Canvas.Top)" />
<Binding ElementName="P3" Path="(Canvas.Left)" />
<Binding ElementName="P3" Path="(Canvas.Top)" />
<Binding ElementName="P4" Path="(Canvas.Left)" />
<Binding ElementName="P4" Path="(Canvas.Top)" />
<Binding ElementName="P5" Path="(Canvas.Left)" />
<Binding ElementName="P5" Path="(Canvas.Top)" />
</MultiBinding>
</Polygon.Points>
</Polygon>
<Ellipse Name="P1" Canvas.Left="50" Canvas.Top="50" />
<Ellipse Name="P2" Canvas.Left="150" Canvas.Top="150" />
<Ellipse Name="P3" Canvas.Left="250" Canvas.Top="250" />
<Ellipse Name="P4" Canvas.Left="50" Canvas.Top="150" />
<Ellipse Name="P5" Canvas.Left="150" Canvas.Top="50" />
</Canvas>