The SortedBindingList is older code. CSLA now supports LINQ and all of its advanced methods.
SBL is limited to a single column sort. LINQ can sort by multiple columns as well as filter the results.
You can use the MS Dynamic Query Library to extend LINQ to sort by strings (instead of lambda expressions.) This is nice for the "click on a column heading" use case.
There have been many posts about LINQ so review a few and ask questions. The result of a query on an editable collection is a type which can be cast to LinqBindingList which is a "view" over the original collection that maintains a cross reference index between the view and the original rows.
HTH
Joe
There's a long thread on the forum that ran around the end of last year on this topic.
The problem/challenge is that WPF doesn't completely work with IBindingList (or BindingList<T>) objects. And Windows Forms doesn't work at all with INotifyCollectionChanged or ObservableCollection<T>.
So CSLA .NET continues to use BindingList<T> as the collection base class, because the alternative is to abandon all Windows Forms support. Unfortunately this means CSLA collections don't fully work with WPF's automatic sorting, etc.
CSLA is not alone in this problem. DataTable and many other types of object are based on IBindingList and don't fully work in WPF. There are blog posts out there with various workarounds, mostly that wrap your collection with an ObservableCollection<T> wrapper.
Thanks Rocky. This is what I was wanting to hear. I am still a little confused as to why IBindinglist<T> is not fully supported by WPF. Even reflecting into BindingListCollectionView I see the call being made to the interal IBindingList<T> collection. See below..
if (sorts.Count > 0)
{
this._isSorted = true;
if (this._blv == null)
{
this.InternalList.ApplySort(sorts[0].PropertyDescriptor, sorts[0].SortDirection);
}
else
{
this._blv.ApplySort(sorts);
}
}
In any case it does not seem to work. I will hunt for the thread you speak of and do some reading.
Brette
I’m confused as to why WPF doesn’t fully support it
either, and I know a lot of people have communicated to Microsoft that this is
a problem.
I haven’t looked at WPF 4 to see if they’ve
addressed the issue, but it can’t be a high priority for them if they
haven’t addressed it after 3+ years…
Rocky
Copyright (c) Marimer LLC