Quantcast
Viewing all articles
Browse latest Browse all 18858

How hide/unhide rows from a wpf data bound DataTemplated ListBox?

I've populated a wpf ListBox (ListBox1) using a DataTemplate in xaml and a System.Data.DataSet in the vb.net code behind.

I wish to "move" rows to and from ListBox1 and ListBox2.

I can copy rows from ListBox1 to ListBox2 using "ListBox2.Items.Add".

I can remove rows from ListBox2 using "ListBox2.Items.RemoveAt".

My question: Is there a simple way to hide rows in ListBox1? (To create the illusion of movement.)

Note: I can't ListBox1.Items.RemoveAt. This triggers the error "Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead". I don't know what this means! Presumably the error occurred because ListBox1 is data-templated and/or data-bound and/or virtualized (because of high row count).

Also note: ListItems are composite controls. I can sort of hide an entire ListItem by setting Visibility="Hidden" in xaml (Intelli-sense doesn't seem to find this, so I don’t know how to do it in code). In any case, it doesn't collapse the ListItem from view, i.e. the space taken by the ListItem is left blank and is not reclaimed.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>