I got some issues while trying to bind an ObservableCollection made from 2 others.
First I need to bind ActiveSketchs, Second i have to bind Sketchs (Which is ActivesSketchs.Union(InactiveSketchs) separately.
I thought the code below would work but it doesn’t. The ActiveSketch binding works correctly, but not the Sketchs one :
private ObservableCollection<Sketch> _sketchs;
public ObservableCollection<Sketch> Sketchs
{
get { return _sketchs = new ObservableCollection<Sketch>(ActiveSketchs.Union(InactiveSketchs)); }
set { _sketchs = value; }
}
private ObservableCollection<Sketch> _activeSketchs;
public ObservableCollection<Sketch> ActiveSketchs
{
get { return _activeSketchs; }
set { _activeSketchs = value; }
}
private ObservableCollection<Sketch> _inactiveSketchs;
public ObservableCollection<Sketch> InactiveSketchs
{
get { return _inactiveSketchs; }
set { _inactiveSketchs = value; }
}
And here’s how i set the source item :
HeadbandRight.ItemsSource = Sketchs;
HeadbandLeft.ItemsSource = Sketchs;
MainScatterViewer.ItemsSource = ActiveSketchs;
You should use a CollectionViewSource to get filtered items from your list :
Full example here : http://uicraftsman.com/blog/2010/10/27/filtering-data-using-collectionviewsource/