ScatterViewItems の間に線を引きたいのですが、ここで既に見つけたものでは機能しません。直線はありますが、楕円の中心に接続されていません。誰かが私の間違いを見ますか?ここに私が持っているものがあります:
<Grid>
<s:ScatterView>
<s:ScatterViewItem Height="250" Width="500" Background="Transparent" Orientation="0" HorizontalAlignment="Right" Margin="0,70,-764,-70" d:LayoutOverrides="HorizontalAlignment, Width">
<s:ScatterView Height="250" Width="500" Background="BlueViolet">
<s:ScatterViewItem Background="Transparent" Center="100,145" Orientation="0">
<Label Content="Knoten A" Background="WhiteSmoke" Foreground="Black"/>
</s:ScatterViewItem>
<s:ScatterViewItem x:Name="StartItem" CanMove="False" CanRotate="False" Margin="0" Center="10,125" Background="Transparent">
<Ellipse Width="10" Height="10" Fill="Transparent" Stroke="Black" Margin="0,0,0,0"/>
</s:ScatterViewItem>
<s:ScatterViewItem x:Name="EndItem" CanMove="False" CanRotate="False" Margin="0" Center="490,125" Background="Transparent">
<Ellipse Width="10" Height="10" Fill="Transparent" Stroke="Black" Margin="0,0,0,0"/>
</s:ScatterViewItem>
<s:ScatterViewItem Background="Transparent">
<Canvas Name="LineHost"/>
</s:ScatterViewItem>
</s:ScatterView>
</s:ScatterViewItem>
</s:ScatterView>
</Grid>
そして、c#
Line line = new Line { Stroke = Brushes.Black, StrokeThickness = 2.0 };
BindLineToScatterViewItems(line, StartItem, EndItem);
LineHost.Children.Add(line);
private void BindLineToScatterViewItems(Line line, ScatterViewItem StartItem, ScatterViewItem EndItem)
{
BindingOperations.SetBinding(line, Line.X1Property,
new Binding {Source = StartItem, Path = new PropertyPath("ActualCenter.X")});
BindingOperations.SetBinding(line, Line.Y1Property,
new Binding { Source = StartItem, Path = new PropertyPath("ActualCenter.Y") });
BindingOperations.SetBinding(line, Line.X2Property,
new Binding { Source = EndItem, Path = new PropertyPath("ActualCenter.X") });
BindingOperations.SetBinding(line, Line.Y2Property,
new Binding { Source = EndItem, Path = new PropertyPath("ActualCenter.Y") });
}