private void Expand() { if (this.Type == DirectoryItemType.File) { return; } this.Children = new ObservableCollection <DirectoryItemViewModel>(DirectoryStructure.GetDirectoryContents(this.FullPath).Select(content => new DirectoryItemViewModel(content.FullPath, content.Type))); }
/// <summary> /// expands this directory and finds all children /// </summary> private void Expand() { // cannot expand file if (this.Type == DirectoryItemType.File) { return; } // returns a List<DirectoryItem> of all the children of the drive. var children = DirectoryStructure.GetDirectoryContents(this.FullPath); // This is creating an ObservableColletion (which sends notifications when it's changed) out of the List<DiscoveryItem> children (looping through the list), // which are first being called and run through DirectoryItemViewModel. this.Children = new ObservableCollection <DirectoryItemViewModel>(children.Select(content => new DirectoryItemViewModel(content.FullPath, content.Type))); }