public MainWindow() { InitializeComponent(); //this.Namesxd = new ObservableCollection<PluginName>(); foreach (string s in Directory.GetLogicalDrives()) { myTreeItem item = new myTreeItem(s); item.Header = s; item.Tag = s; item.FontWeight = FontWeights.Normal; item.Items.Add(dummyNode); item.Expanded += new RoutedEventHandler(folder_Expanded); trvMenu.Items.Add(item); } LoadPlugins(); //System.Windows.MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory.ToString()); }
private void folder_Expanded(object sender, RoutedEventArgs e) { myTreeItem item = (myTreeItem)sender; if (item.Items.Count == 1 && item.Items[0] == dummyNode) { item.Items.Clear(); try { foreach (string s in Directory.GetDirectories(item.Tag.ToString())) { myTreeItem subitem = new myTreeItem(s); subitem.Header = s.Substring(s.LastIndexOf("\\") + 1); subitem.Tag = s; subitem.FontWeight = FontWeights.Normal; subitem.Items.Add(dummyNode); subitem.Expanded += new RoutedEventHandler(folder_Expanded); item.Items.Add(subitem); } } catch (Exception) { } } }