How do I bind a List to an ItemsControl?

后端 未结 2 1677
清歌不尽
清歌不尽 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:

    <ItemsControl ItemsSource="{Binding PropertyNames}"/>
    

    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.
    0 讨论(0)
  • 2021-02-13 05:51

    let me answer this, it's just {Binding}.

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