What's the difference between ItemTemplate and ItemContainerStyle in a WPF ListBox?

后端 未结 2 959
萌比男神i
萌比男神i 2020-12-13 06:23

In WPF Listbox, I\'m confused with these 2 notions: ItemTemplate and ItemContainerStyle Can someone explain me more?

2条回答
  •  有刺的猬
    2020-12-13 06:57

    The ItemContainerStyle just a wrapper for the DataTemplate so that a common item style can be applied to different data layouts.

    Also, from this answer to "DataTemplate vs ItemContainerStyle":

    You can do all your styling in the ItemTemplate but the ItemContentStyle has VisualStates which control the Opacity on mouse over/disabled/selected etc.

    If you want to change those opacity state changes, or if you want any Container shape other than a rectangle, like a triangle for example, then you'll have to override the default ItemContainerStyle.

提交回复
热议问题