private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { FileExplorerItem item = sender as FileExplorerItem; if (item != null && item.IsSelected) { NotifyPropertyChanged("SelectedItem"); } }
private static FileExplorerItem GetSelectedItem(IEnumerable <FileExplorerItem> items) { //top-level items: FileExplorerItem item = items.FirstOrDefault(i => i.IsSelected); if (item == null) { //sub-level items; IEnumerable <FileExplorerItem> subItems = items.OfType <Directory>().SelectMany(d => d.SubItems); if (items.Any()) { item = GetSelectedItem(subItems); } } return(item); }