在下面的 XAML 中,请填写“WhatGoesHere”节点并向我解释如何不会弄乱Canvas
.
<ItemsControl ItemsSource="{Binding ViewModels}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<WhatGoesHere?>
<Path Stroke="CornflowerBlue" StrokeThickness="2">
<Path.Data>
<PathGeometry Figures="{Binding Figures}"/>
</Path.Data>
</Path>
<Path Stroke="Red" StrokeThickness="2">
<Path.Data>
<PathGeometry Figures="{Binding Figures2}"/>
</Path.Data>
</Path>
</WhatGoesHere?>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我的示例在模板中有两个相同类型的对象,但我也会在其中有几个其他控件类型。