我在我的MainViewModel中使用此函數作爲我的列表框的itemssource ...但我不知道如何按字母順序對它們進行排序。請幫我按字母排序列表中的項目?
public void LoadData()
{
if (Data == null)
{
var oderedFullName = (from Member b in MemberDB.Members
select b).OrderBy(b => b.FullName);
Data = new ObservableCollection<Member>(oderedFullName);
}
}
也試過這樣:
public void LoadData()
{
if (Data == null)
{
var oderedFullName = from Member b in MemberDB.Members
orderby b.FullName
select b;
Data = new ObservableCollection<Member>(oderedFullName);
}
}
和Show.xaml加載它
public Show()
{
InitializeComponent();
this.DataContext = App.MainViewModel;
App.MainViewModel.LoadData();
}
沒有人能幫助我嗎? :( – user3084513