Hi team,
I'm having a problem with GroupDescriptors in RadGridView. I have a grid which have 2 columns are "First Name" and "Last Name", and I want to group by "First Name" column. I do like this:
MainPage.xaml:
<Controls:RadGridView Grid.Column="0" x:Name="lstView" AutoGenerateColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto" >
<Controls:RadGridView.GroupDescriptors>
<Data:GroupDescriptor Member="FirstName" >
</Data:GroupDescriptor>
</Controls:RadGridView.GroupDescriptors>
<Controls:RadGridView.Columns>
<Controls:GridViewDataColumn Header="First Name"
DataMemberBinding="{Binding Path=FirstName}"/>
<Controls:GridViewDataColumn Header="Last Name"
DataMemberBinding="{Binding Path=LastName}"/>
</Controls:RadGridView.Columns>
</Controls:RadGridView>
And code behind (MainPage.xaml.cs):
using
System.Collections.ObjectModel;
using
System.ComponentModel;
using
System.Windows;
using
System.Windows.Data;
namespace
SilverlightApplication28
{
public partial class MainPage : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if ((propertyChanged != null))
{
propertyChanged(
this, new PropertyChangedEventArgs(propertyName));
}
}
private PagedCollectionView _listUsers;
public PagedCollectionView ListUsers
{
get { return _listUsers; }
set
{
_listUsers =
value;
NotifyPropertyChanged(
"ListUsers");
}
}
public MainPage()
{
InitializeComponent();
Loaded+=MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var user1 = new User("Nguyen", "Cuong");
var user2 = new User("Nguyen", "Tu");
var users = new ObservableCollection<User> { user1, user2 };
ListUsers =
new PagedCollectionView(users);
lstView.ItemsSource = ListUsers;
}
}
}
But it doesn't work.
Please help me !
Thanks,
Triet