경로의 크기와 높이를 배율 인수로 사용하여 PathGeometry 크기의 경로를 만들 수 있습니다. 아래 그림과 같이
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button HorizontalAlignment="Left" Margin="5" Content="Button"/>
<Canvas x:Name="polylineCanvas" Grid.Row="1">
<Path Stroke="Blue" StrokeThickness="3">
<Path.Data>
<PathGeometry x:Name="polyline">
<PathGeometry.Transform>
<ScaleTransform
ScaleX="{Binding ActualWidth, ElementName=polylineCanvas}"
ScaleY="{Binding ActualHeight, ElementName=polylineCanvas}"/>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
</Grid>
지금 당신이 코드의 형상을 지정할 수 있습니다 :
var points = new Point[]
{
new Point(0.1, 0.1),
new Point(0.9, 0.1),
new Point(0.9, 0.9),
new Point(0.1, 0.9)
};
var figure = new PathFigure
{
StartPoint = points[0],
IsClosed = true
};
var segment = new PolyLineSegment(points.Skip(1), true);
figure.Segments.Add(segment);
polyline.Figures.Add(figure);
당신은 선택적으로 사용할 수있다 따라서 당신은 어느 방향으로 0에서 1까지의 논리적 좌표로 전체 형상을 지정할 수 있습니다 pathGeometry 대신 StreamGeometry입니다.
대단히 감사합니다! 나는 뒤에있는 코드에서 바인딩을 할 수 있었고, 많은 것을 배웠고 마침내 나아갈 패턴을 얻었다. – egon12