Bir alakalı kod örneği olmadan sorunu teşhis etmek biraz zor, ama belki sorun aynı çokgen eklemek çalıştı olmasıdır tuval 'iki kez çocuklara. Ben senin hata mesajı ile bunu çöker başka canvas.Children.Add poly
eklerseniz
type SimpleWindow() as this =
inherit Window()
do
let makepoly size corners =
let size = 192.0
let angle = 2.0 * Math.PI/float corners
let getcoords size angle = new Point(size * cos angle, size * sin angle)
let poly = new Polygon(Fill = Brushes.Red)
poly.Points <- new PointCollection([for i in 0..corners-1 -> getcoords size (float i * angle)])
poly
let canvas = new Canvas(HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center)
let poly = makepoly 192.0 5
Canvas.SetLeft(poly, canvas.Width/2.0)
Canvas.SetTop(poly, canvas.Width/2.0)
canvas.Children.Add poly |> ignore //this works
this.AddChild canvas |> ignore
SimpleWindow().Show()
:
Bu
Ben senin hatayı yeniden kadar burped koddur.
canvas.Children.Add poly |> ignore
canvas.Children.Add poly |> ignore //this fails, poly already exists on the canvas
hatayı düzeltmek için, ben ilk bir yenisi ile değiştirilmesi amacıyla mevcuttu belirli çocuğu kaldırmak için
canvas.Children.Remove
çağırdı.
canvas.Children.Add poly |> ignore
canvas.Children.Remove poly
canvas.Children.Add poly |> ignore //this works, because the previous version is gone
Bu sorununuzu düzeltir umuyoruz.
Teşekkürler cfern. Şimdi WPF'de biraz daha uzağım. Geç yanıt için özür dilerim ... –