Hi,
my ItemSource contains an ObservableCollection of Players, (taken from the GridViewComboBoxColumn-ChangeDataContext.zip)
where Player has an extra property, a class named CombinedID. It is defined as
So, Player has the following properties (excerpt):
Unfortunately, despite all the implemented interfaces, the DataGrid column containing this CombinedId refuses sorting. It just does nothing.
The XAML code for the extra column is
and I have tried SortMemberPath="DbId" and SortMemberPath="ID.DbId"
but nothing seems to work.
Can you please give me a hint why this column cannot be sorted?
my ItemSource contains an ObservableCollection of Players, (taken from the GridViewComboBoxColumn-ChangeDataContext.zip)
where Player has an extra property, a class named CombinedID. It is defined as
public
partial
class
CombinedID
: INotifyPropertyChanged
, IEquatable<CombinedId>
, IComparable<CombinedId>
, IEqualityComparer<CombinedId>
{
private
int
DbIdField;
private
Guid GuidField;
public
CombinedID(
int
i, Guid guid){
DbId = i;
Guid = guid;
}
public
int
DbId {
get
{
return
this
.DbIdField; }
set
{
if
((
this
.DbIdField.Equals(value) !=
true
)) {
this
.DbIdField = value;
this
.RaisePropertyChanged(
"DbId"
);
}
}
}
public
System.Guid Guid {
get
{
return
this
.GuidField; }
set
{
if
((
this
.GuidField.Equals(value) !=
true
)) {
this
.GuidField = value;
this
.RaisePropertyChanged(
"Guid"
);
}
}
}
public
event
PropertyChangedEventHandler PropertyChanged;
protected
void
RaisePropertyChanged(
string
propertyName) {
PropertyChangedEventHandler propertyChanged =
this
.PropertyChanged;
if
((propertyChanged !=
null
)) {
propertyChanged(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
public
override
string
ToString() {
return
DbId.ToString();
}
public
bool
Equals(CombinedID other) {
// for IEquitable<T>
if
(other ==
null
)
return
false
;
return
this
.DbId == other.DbId;
}
public
bool
Equals(CombinedID a, CombinedID b) {
// for IEqualityComparer<T>
if
(a !=
null
&& b !=
null
)
return
a.DbId == b.DbId;
if
(a ==
null
&& b ==
null
)
return
true
;
return
false
;
}
public
int
CompareTo(CombinedID other) {
// for IComparable<T>
if
(other ==
null
)
return
1;
return
this
.DbId.CompareTo(other.DbId);
}
public
override
int
GetHashCode() {
// for IEquitable<T>
return
DbId.GetHashCode() ^ Guid.GetHashCode();
}
public
int
GetHashCode(CombinedID a) {
// for IEqualityComparer<T>
return
a.GetHashCode();
}
}
So, Player has the following properties (excerpt):
- public int SortID
- public string Name
- public CombinedID ID
Unfortunately, despite all the implemented interfaces, the DataGrid column containing this CombinedId refuses sorting. It just does nothing.
The XAML code for the extra column is
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding ID}"
/>
but nothing seems to work.
Can you please give me a hint why this column cannot be sorted?