Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit DataGrid column sorting
5 replies. Latest Post by lijoputhuval on May 29, 2009.
(0)
hotfrost
Member
45 points
22 Posts
05-27-2009 10:35 PM |
Hello everyone,
question;
is it possible to call sorting on one of the columns programatically in datagrid??
one more question:
how to change the itemssource for datagrid?
when i am switching for new itemssource the datagrid still displays the old data.
and there is no method Bind() to refresh the datagrid...
Thanks in advance!
Alex
meykih
Participant
876 points
213 Posts
05-28-2009 9:47 AM |
To your second question: Inside your datagrid columns you use databinding? Did you use INotifyPropertyChanged in your source data?
05-28-2009 10:04 AM |
no i didn't.. i resolved the problem first to set the datasource to null, and then again to bind it to datagrid.
thanks,
al
gunjansh...
526 points
88 Posts
05-28-2009 2:26 PM |
HotFrost:is it possible to call sorting on one of the columns programatically in datagrid??
Yes, with Silverlight 3 Beta, you can use SortDescriptions to sort a column programatically, following sample should help:
using System.ComponentModel; dataGrid.SortDescriptions.Add(new SortDescription("Property1" /*Bound to Column1*/, ListSortDirection.Ascending));
dataGrid.SortDescriptions.Add(
You can even use this to have your columns initially sorted.
Gunjan [MSFT]
yifung
Contributor
3313 points
540 Posts
05-28-2009 6:58 PM |
For the items not updating, if you use an ObservableCollection as your ItemsSource
lijoputh...
108 points
51 Posts
05-29-2009 7:01 AM |
Ya Observable Collection Is the Best Option To Set Item Source in DataGrid.
Try Like This..
public ObservableCollection<ClientListCommon> ClientList = new ObservableCollection<ClientListCommon>();
{
}
Please Mark As Answer if This Helps You