Beispiel #1
0
        public FolderTreeViewModel()
        {
            var drives = Directory.GetLogicalDrives();

            foreach (var item in drives)
            {
                var treeItem = new DirectoryItemViewModel(item.Remove(item.Length - 1), null);
                treeItem.PropertyChanged += TreeItemPropertyChanged;
                treeItem.ItemAdded       += TreeItemItemAdded;
                treeItem.ItemRemoved     -= TreeItemItemRemoved;
                this._treeRoot.Add(treeItem);
            }
        }
Beispiel #2
0
        private void TreeItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "IsSelected")
            {
                return;
            }

            var treeItem = sender as DirectoryItemViewModel;

            if (this._selectedTreeItem != null && this._selectedTreeItem != treeItem)
            {
                this._selectedTreeItem.IsSelected = false;
            }

            this._selectedTreeItem = treeItem;
            if (treeItem == null)
            {
                SelectedPath = string.Empty;
                return;
            }

            SelectedPath = treeItem.FullPath ?? string.Empty;
        }