私はObservable Collectionに自分のデータ値が含まれています。 Orderbyをコレクションに使用したいが、 "Cannot convert IEnumurable to ObservableCollection"
のような例外がいくつか出てきている。 OrderByを利用するか、いくつかのオプションをに教えてください。を並べ替えるのですか?Observableコレクションの新しいインスタンスを作成せずにIEnumurableをObservableコレクションに変換します。
誰でも私にこの解決方法を教えてください。 ありがとうございます。
私のコードは次のとおり
get {
return _availableStocks == null ? null : _availableStocks .OrderBy(z => z.Casepack.CasePackContents);
// Here _availableStocks is my collection
//Here i am not able to use orderby in this collection Its showing error line
// Here i need to sort the _availableStocks
}
私の実際のコードは次のとおり
foreach (var cachedStock in AvailableSelectedStocks)
{
if (SelectedStock != null)
{
AvailableStocks= CollectionViewSource.GetDefaultView(_availableStocks);
AvailableStocks.SortDescriptions.Add(new SortDescription(SelectedStock.Casepack.CasePackContents.Count.ToString(), ListSortDirection.Ascending));
//In this above line i am getting the Sort descriptions only i am not getting the datas in the SourceCollection . how can i get values in this Collection
this.SelectedStocks.Remove(SelectedStock);
this.RaisePropertyChanged(Member.Of(() => AvailableStocks));
}
}
例外またはコンパイラエラー?あなたはどのようにそのプロパティが使用されているかを示すことができますか? –
コンパイルエラー – SuryaKavitha