次のように ItemsControl を設定しています。
<Grid>
<ItemsControl ItemsSource="{Binding Asteroids}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="Black">
<!-- i want to add another polygon to the canvas-->
<!--<Polygon Name ="ShipPolygon" Points="{Binding Ship}" Fill="Blue" />-->
</Canvas>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Polygon Fill="Gray" Points="{Binding AsteroidPoints}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
ご覧のとおり、ItemsControl はコレクションの要素を Canvas 内の Polygon として表示しています。しかし、ここでは「ShipPolygon」という名前の別のポリゴンをこのキャンバスに追加したいと考えています。XMLParseException が発生するため、この方法では実行できません。これを行う適切な方法は何ですか?前もって感謝します!