안녕 얘들 아, WPF의 경로 모양으로 놀아 왔지만 약간의 행동으로 약간 짜증났다. 특히 경로는 내가 원하는대로 크기가 조정되지 않습니다. 아래 이미지를 보면, 내가 원하는 것은 전체 패스가 흰색 사각형 (Path 컨트롤의 경계를 나타냄) 내에있는 것입니다. 그러나 호가 약간 늘어져 있습니다. 패스 모양 자체를 그리는 데 사용 된 점에 따라 패스 크기 자체가 실제로 그려지는 모양이 아닌 때문입니다.WPF 경로 크기 조정 문제
내 질문은 : 누구든지 이것을 극복하는 방법을 알고 있습니까? 경로의 크기를 명시 적으로 설정하는 것 외에도 말입니다. 모양을 만드는 데 사용 된 점이 아닌 모양에 따라 크기 자체에 대한 경로를 얻으려면 간과 한 옵션이 있습니까? 어떤 답변을 주셔서 감사합니다.
1) 먼저, 매우 자세한 방법으로 기록 된 데이터 바인딩()를 사용하여 :
<UserControl x:Class="OrbitTrapWpf.LineSegmentTool"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OrbitTrapWpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="Root" Background="White">
<UserControl.Resources>
<local:ArcSizeConverter x:Key="ArcSizeConverter"/>
<local:ArcPointConverter x:Key="ArcPointConverter"/>
</UserControl.Resources>
<Path Name="path" Stroke="Black">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True">
<PathFigure.StartPoint>
<Binding ElementName="Root" Path="point0"></Binding>
</PathFigure.StartPoint>
<PathFigure.Segments>
<PathSegmentCollection>
<ArcSegment SweepDirection="Counterclockwise" >
<ArcSegment.Size>
<Binding ElementName="Root" Path="Radius" Converter="{StaticResource ArcSizeConverter}"/>
</ArcSegment.Size>
<ArcSegment.Point>
<Binding ElementName="Root" Path="point1" />
</ArcSegment.Point>
</ArcSegment>
<LineSegment>
<LineSegment.Point>
<Binding ElementName="Root" Path="point2" />
</LineSegment.Point>
</LineSegment>
<ArcSegment SweepDirection="Counterclockwise">
<ArcSegment.Size>
<Binding ElementName="Root" Path="Radius" Converter="{StaticResource ArcSizeConverter}"/>
</ArcSegment.Size>
<ArcSegment.Point>
<Binding ElementName="Root" Path="point3" />
</ArcSegment.Point>
</ArcSegment>
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
여기 (해야한다 무엇을) 해당 코드의 두 가지 버전의
2) 미니 언어를 사용하는이 사람 :
<UserControl x:Class="OrbitTrapWpf.LineSegmentTool"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OrbitTrapWpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="Root" Background="White">
<UserControl.Resources>
<local:ArcSizeConverter x:Key="ArcSizeConverter"/>
<local:ArcPointConverter x:Key="ArcPointConverter"/>
</UserControl.Resources>
<Grid Name="grid">
<Path Name="path" Stroke="Black" Data="M 0.146446609406726,1.14644660940673 A 0.5,0.5 0 1 0 0.853553390593274,1.85355339059327 L 1.85355339059327,0.853553390593274 A 0.5,0.5 0 1 0 1.14644660940673,0.146446609406726 Z " />
나는 두 언어가 대략 동일해야한다고 생각했지만, 원래 미니 언어 버전은 거의 정확하게, 원본은 많이 다르다.
으로 할 수있는 일 : 여기에 우리의 예를 복용하면 색상을 제어하는 방법입니다 나는 첫 번째 표본에 대해서도 추론했다. 그러나 미니 언어를 사용했을 때 다르게 작동합니다. 그 경우에, 그것은 (거의) 완벽하게 경계 지어졌습니다. –
두 번째 예제에서 경로 데이터는 어디에서 왔습니까? –
첫 번째 예제는 데이터 바인딩에서 데이터를 가져 와서 데이터를 수동으로 가져 와서 두 번째 예제의 데이터 문자열에 연결했습니다. –