Absolute z-order (across several DataTemplates)

后端 未结 1 1958
野性不改
野性不改 2020-12-21 20:17

Ive a ListBox with a Canvas ItemsPanel that displays 2 different types of objects: NodeVMs and LinkLineVMs (using a CompositeCollection). Each VM object has a DataTemplate:

1条回答
  •  再見小時候
    2020-12-21 20:42

    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

    
    

    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

    0 讨论(0)
提交回复
热议问题