I have a collection of UserControls:
ObservableCollection(MyUserControl> MyCollection;
I display the collection in my ListBox by using the following code:
MyListBox1.ItemsSource = MyCollection;
I have another ListBox where I would like to display the same collection of UserControls:
MyListBox2.ItemsSource = MyCollection;
The problem is that when I set the ItemSource on the second Listbox the content of the first ListBox disappear. By d开发者_StackOverflow中文版ebugging I can see that the first ListBox still contain the same items but they just disappear from the GUI.
Is it not possible to display the same UserControl several times?
No, when you add control to other place (other container) it is removed from old place. Control has only one parent.
You have to create copy of those controls to add them to other listbox
精彩评论