Windows phone 7 排序嵌套可观察集合
在我的WP7项目中,我使用嵌套的可观察集合。但是,我的问题是按排序此嵌套集合,并按其嵌套集合的降序排序 收集的数据结构:Windows phone 7 排序嵌套可观察集合,windows-phone-7,c#-4.0,Windows Phone 7,C# 4.0,在我的WP7项目中,我使用嵌套的可观察集合。但是,我的问题是按排序此嵌套集合,并按其嵌套集合的降序排序 收集的数据结构: public class SubCategory : INotifyPropertyChanged { private string _catName; public string CatName { get { return _catName; } set { _catName
public class SubCategory : INotifyPropertyChanged
{
private string _catName;
public string CatName
{
get { return _catName; }
set
{
_catName = value; NotifyPropertyChanged("CatName");
}
}
private ObservableCollection<ToDoList> _lists;
public ObservableCollection<ToDoList> Lists
{
get { return _lists; }
set
{
if (_lists != value)
{
_lists = value;
NotifyPropertyChanged("lists");
}
}
}
公共类子类别:INotifyPropertyChanged
{
私有字符串_catName;
公共字符串CatName
{
获取{return\u catName;}
设置
{
_catName=值;NotifyPropertyChanged(“catName”);
}
}
私有可观察收集列表;
公共可观测收集列表
{
获取{返回_列表;}
设置
{
如果(_list!=值)
{
_列表=值;
NotifyPropertyChanged(“列表”);
}
}
}
这是嵌套集合
public class ToDoList : INotifyPropertyChanged//, INotifyPropertyChanging
{
#region NotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
#region NotifyPropertyChanging Members
// public event PropertyChangingEventHandler PropertyChanging;
/* private void NotifyPropertyChanging(string propertyName)
{
if (PropertyChanging != null)
PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
}*/
#endregion
[Column(IsVersion = true)]
private Binary _version;
private int _ItemId;
[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public int ItemId
{
get { return _ItemId; }
set
{
if (_ItemId != value)
{
//NotifyPropertyChanging("ItemdId");
_ItemId = value;
NotifyPropertyChanged("ItemId");
}
}
}
private string _ItemTitle;
[Column]
public string ItemTitle
{
get { return _ItemTitle; }
set
{
if (_ItemTitle != value)
{
//NotifyPropertyChanging("ItemTitle");
_ItemTitle = value;
NotifyPropertyChanged("ItemTitle");
}
}
}
private double _ItemLatitude;
[Column]
public double ItemLatitude
{
get { return _ItemLatitude; }
set
{
if (_ItemLatitude != value)
{
//NotifyPropertyChanging("ItemLatitude");
_ItemLatitude = value;
NotifyPropertyChanged("ItemLatitude");
}
}
}
private string _ItemAddress;
[Column]
public string ItemAddress
{
get { return _ItemAddress; }
set
{
if (_ItemAddress != value)
{
//NotifyPropertyChanging("ItemAddress");
_ItemAddress = value;
NotifyPropertyChanged("ItemAddress");
}
}
}
private double _ItemLongtitude;
[Column]
public double ItemLongtitude
{
get { return _ItemLongtitude; }
set
{
if (_ItemLongtitude != value)
{
//NotifyPropertyChanging("ItemLongtitude");
_ItemLongtitude = value;
NotifyPropertyChanged("ItemLongtitude");
}
}
}
private string _ItemDescription;
[Column]
public string ItemDescription
{
get { return _ItemDescription; }
set
{
if (_ItemDescription != value)
{
//NotifyPropertyChanging("ItemDescription");
_ItemDescription = value;
NotifyPropertyChanged("ItemDescription");
}
}
}
private bool isScheduled;
[Column]
public bool IsScheduled
{
get { return isScheduled; }
set
{
if (isScheduled != value)
{
//NotifyPropertyChanging("IsScheduled");
isScheduled = value;
NotifyPropertyChanged("IsScheduled");
}
}
}
private string _reminderId;
[Column]
public String ReminderId
{
get { return _reminderId; }
set
{
if (_reminderId != value)
{
//NotifyPropertyChanging("ReminderId");
_reminderId = value;
NotifyPropertyChanged("ReminderId");
}
}
}
private String _ItemTime;
[Column]
public String ItemTime
{
get { return _ItemTime; }
set
{
if (_ItemTime != value)
{
//NotifyPropertyChanging("ItemTime");
_ItemTime = value;
NotifyPropertyChanged("ItemTime");
}
}
}
private bool _isComplete;
[Column]
public bool IsComplete
{
get { return _isComplete; }
set
{
if (_isComplete != value)
{
//NotifyPropertyChanging("IsComplete");
_isComplete = value;
NotifyPropertyChanged("IsComplete");
}
}
}
private char _importance;
[Column]
public char Importance
{
get { return _importance; }
set
{
if (_importance != value)
{
//NotifyPropertyChanging("Importance");
_importance = value;
NotifyPropertyChanged("Importance");
}
}
}
[Column]
internal int _categoryId;
private EntityRef<Category> _category;
public Category ToDoCategory
{
get { return _category.Entity; }
set
{
//NotifyPropertyChanging("ToDoCategory");
_category.Entity = value;
if (value != null)
{
_categoryId = value.CategoryId;
}
//NotifyPropertyChanging("ToDoCategory");
}
}
}
public类ToDoList:INotifyPropertyChanged/,INotifyPropertyChanging
{
#区域NotifyPropertyChanged成员
公共事件属性更改事件处理程序属性更改;
私有void NotifyPropertyChanged(字符串propertyName)
{
if(PropertyChanged!=null)
PropertyChanged(这是新的PropertyChangedEventArgs(propertyName));
}
#端区
#区域通知属性更改成员
//公共事件属性更改EventHandler属性更改;
/*私有void notifyPropertyChangeg(字符串propertyName)
{
if(PropertyChange!=null)
PropertyChange(这是新的PropertyChangingEventArgs(propertyName));
}*/
#端区
[列(IsVersion=true)]
私有二进制版本;
私有int_ItemId;
[列(IsPrimaryKey=true,IsDbGenerated=true,DbType=“INT NOT NULL Identity”,CanBeNull=false,AutoSync=AutoSync.OnInsert)]
公共int ItemId
{
获取{return\u ItemId;}
设置
{
if(_ItemId!=值)
{
//NotifyPropertyChange(“ItemdId”);
_ItemId=值;
NotifyPropertyChanged(“ItemId”);
}
}
}
私有字符串_ItemTitle;
[专栏]
公共字符串ItemTitle
{
获取{return\u ItemTitle;}
设置
{
if(_ItemTitle!=值)
{
//NotifyPropertyChange(“项目名称”);
_ItemTitle=值;
NotifyPropertyChanged(“ItemTitle”);
}
}
}
私人双项自由;
[专栏]
公共双项目纬度
{
获取{return\u ItemLatitude;}
设置
{
如果(_ItemLatitude!=值)
{
//NotifyPropertyChange(“项目纬度”);
_项目纬度=值;
NotifyPropertyChanged(“ItemLatitude”);
}
}
}
私有字符串_ItemAddress;
[专栏]
公共字符串项地址
{
获取{return\u ItemAddress;}
设置
{
if(_ItemAddress!=值)
{
//NotifyPropertyChange(“项目地址”);
_ItemAddress=值;
NotifyPropertyChanged(“项目地址”);
}
}
}
私人双重性;
[专栏]
公共双项目
{
获取{return\u ItemLongtitude;}
设置
{
if(_itemLongtude!=值)
{
//NotifyPropertyChange(“ItemLongtude”);
_项目长度=价值;
NotifyPropertyChanged(“ItemLongtude”);
}
}
}
私有字符串_itemsdescription;
[专栏]
公共字符串项描述
{
获取{return\u itemsdescription;}
设置
{
if(_itemsdescription!=值)
{
//NotifyPropertyChange(“项目描述”);
_ItemDescription=值;
NotifyPropertyChanged(“项目描述”);
}
}
}
私人住宅已预定;
[专栏]
公共图书馆已排定日程
{
获取{return isScheduled;}
设置
{
如果(isScheduled!=值)
{
//通知财产变更(“已安排”);
isScheduled=值;
NotifyPropertyChanged(“IsScheduled”);
}
}
}
私有字符串\u提醒ID;
[专栏]
公共字符串提醒ID
{
获取{return\u rementerid;}
设置
{
如果(_rementerId!=值)
{
//NotifyPropertyChange(“提醒ID”);
_提醒ID=值;
NotifyPropertyChanged(“提醒ID”);
}
}
}
私有字符串_ItemTime;
[专栏]
公共字符串ItemTime
{
获取{return\u ItemTime;}
设置
{
if(_ItemTime!=值)
{
//NotifyPropertyChange(“ItemTime”);
_ItemTime=值;
NotifyPropertyChanged(“ItemTime”);
}
}
}
私人住宅已完工;
[专栏]
公共图书馆已完工
{
获取{return\u isComplete;}
设置
{
如果(_isComplete!=值)
{
//通知财产变更(“完成”);
_isComplete=值;
NotifyPropertyChanged(“IsComplete”);
}
}
}
私人性质的重要性;
[专栏]
公众角色的重要性
{
获取{return\u重要性;}
设置
{
如果(_重要性!=值)
{
//通知财产变更(“重要性”);
_重要性=价值;
通知财产变更(“重要性”);
}
}
}
[专栏]
内部int_类别ID;
私有实体ref_类别;
公共类别定位
{
获取{return}category.Entity;}
设置
{
//NotifyPropertyChange(“T
public ObservableCollection<ToDoList> Lists
{
get
{
var l = from ToDoList lis in _lists
orderby lis.ItemId descending
select lis;
return new ObservableCollection<ToDoList>(l);
}
set
{
if (_lists != value)
{
_lists = value;
NotifyPropertyChanged("lists");
}
}
}