【发布时间】:2018-07-12 13:28:43
【问题描述】:
我在 wpf 中有以下 XAML
<Canvas>
<ItemsControl ItemsSource="{Binding CompositeCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type Type1}">
<Shape1/>
</DataTemplate>
<DataTemplate DataType="{x:Type type2}">
<Shape2/>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Canvas>
所以基本上我有两个不同的数据模板,用于我的System.Windows.Data.CompositeCollection 可能包含的两种不同类型。然后根据类型绘制 Shape1 或 Shape2。
我需要 shape1 的 zindex 高于 shape2,所以我需要从 dataTemplate 设置 zindex。
我该怎么做?
【问题讨论】:
-
Panel.ZIndex = xyz不工作? -
@Lennart 我会把它放在哪里?
-
这能回答你的问题吗? Binding ZIndex from DataTemplate