Set your ZIndex index in ListBox.ItemContainerStyle
instead of your DataTemplate.
The reason for this is that all items are wrapped in a ListBoxItem
, so you need to set the ZIndex on the ListBoxItem
instead of on the DataTemplate
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Canvas.ZIndex"
Value="{Binding Converter={StaticResource GetObjectZIndexConverter}}" />
</Style>
You'll need a converter that checks the typeof
your databound object, and returns the correct ZIndex based on if it's a NodeVM
or NetworkLinkVM
.
This will only set the ZIndex for your DataTemplates, but once those are sorted out, you can set the ZIndex of NetworkLinkVM's
internal Line
and TextBlock
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…