Why is this XAML getting the error: Items collection must be empty before using ItemsSource

后端 未结 3 1392
鱼传尺愫
鱼传尺愫 2021-01-04 07:13

Can anyone conjure from this code why the ItemsSource line would be getting a

Items collection must be empty before using

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 07:33

    You are trying to set the ItemsSource of the ItemsControl but you already have children. Which of those two should apply? The Button you put inside the ItemsControl or the collection you are handing into it as ItemsSource? The error message is perfectly reasonable.

    You would have to either remove the button from the ItemsControl or remove the ItemsSource attribute. You can't insert items and set ItemsSource at the same time.

提交回复
热议问题