WPF - ItemTemplate not acting as expected

后端 未结 5 2029
野的像风
野的像风 2021-01-14 02:25

I have a UserControl which I\'m using to display a list of UIElements. The control consists of a single ItemsControl with it\'s

5条回答
  •  执念已碎
    2021-01-14 03:03

    Robert Macnee nailed the reason on the head. His solution involves using the control template which might be overkill for a given scenario. Alternatively, use a ListBox - set the ItemContainerStyle to a new Style for ListBoxItem, and in that style, set the ContentTemplate to the DataTemplate that you wanted to use in the ListBox ItemTemplate.

提交回复
热议问题