Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DataGrid filtering

$
0
0

Suppose I have a collection of regions (ObservableCollection<Regions> AllRegions) where a region is defined as either a rectangle or a circle. A ComboBox holds a list of the different region types in the collection (i.e. Rectangle, Circle) and a DataGrid will display all the items in the collection of that type.

When the User selects a region type from the ComboBox I can grab all the items of that type and populate a property with the list of these regions (CurrentRegions) that is bound to the DataGrid. 

CurrentRegions = Regions.Where(x=>x.GetType()== typeof(Rectangle)) as ObservableCollection<Rectangle>;

If the type is rectangle then the data grid has five columns (minX, minY, maxX, maxY, color). If the user selected the Circle type then the DataGrid displays two columns (radius, color)

What I cannot figure out is how to populate the changes back into collection that has all the regions.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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