How do I bind a List to an ItemsControl?

后端 未结 2 1680
清歌不尽
清歌不尽 2021-02-13 05:10

In my presenter I have this property:

public List PropertyNames { get; set; }

And I want to list out the names with a ItemsContro

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 05:28

    An easier way to accomplish the same thing is to simply use:

    
    

    By default, this will create a vertical StackPanel and add each element in its own TextBlock. According to MSDN, this works for any of the following:

    • A string.
    • A DateTime object.
    • A UIElement object.
    • A Panel control that contains an Ellipse and a TextBlock.

提交回复
热议问题