Ejemplo n.º 1
0
        public Window1ViewModel()
        {
            var drives = Directory.GetLogicalDrives();

            foreach (var drive in drives)
            {
                var treeItem = new TreeViewItemViewModel
                               (
                    type: ItemModel.Types.Drive,
                    fullpath: drive,
                    isRoot: true
                               );
                treeItem.Expanded += TreeViewItem_Expanded;
                treeItem.Selected += TreeViewItem_Selected;
                TreeViewItems.Add(treeItem);

                var listItem = new ListViewItemViewModel
                               (
                    type: ItemModel.Types.Drive,
                    fullpath: drive,
                    isRoot: true
                               );
                listItem.Selected += ListViewItem_Selected;
                ListViewItems.Add(listItem);
            }
        }
Ejemplo n.º 2
0
 public void TreeViewItem_Selected(object sender, EventArgs e)
 {
     // sender must be the original sender of this event
     if (!(sender is TreeViewItemViewModel treeViewModel))
     {
         Console.WriteLine("Invalid sender");
         return;
     }
     // update list view according to the selected folder in treeview
     ListViewItems.Clear();
     foreach (var treeViewItem in treeViewModel.Items)
     {
         var listViewItem = new ListViewItemViewModel(treeViewItem.Model);
         listViewItem.Selected += ListViewItem_Selected;
         ListViewItems.Add(listViewItem);
     }
 }