ObservableCollection<Object>
には、Directory
とFile
の2種類のオブジェクトがあります。このコレクションはコントロールにバインドされており、しばらくしてFile
を除外したいと考えています。フィルターオブジェクトObservableCollection 何らかのタイプ
私が働いていない次のコードを、持っている:
var files = (from File f in (from Directory d in selectedDirs
select d.Childs)
where f is File
select f);
を、私はこのエラーを取得しています:
Unable to cast object of type 'System.Collections.ObjectModel.ObservableCollection`1[System.Object]' to type 'CMBraga_FileExplorer.File'.
はどうやって値を得ることができますか?私は彼らがFile
であることを知っています。
// this was ran without explicit conversion (just as an example)
? myCollection
Count = 5
[0]: {CMBraga_FileExplorer.File}
[1]: {CMBraga_FileExplorer.File}
[2]: {CMBraga_FileExplorer.File}
[3]: {CMBraga_FileExplorer.File}
[4]: {CMBraga_FileExplorer.File}
これはうまくいった!大変ありがとうございます! –