I've never used WPF before, so I'm having some trouble. I'm using VS2008 and coding in C#.
I've declared a TreeView object in XAML like this:
Now, I want to populate the treeview when the application loads so that it shows all of the available directories. It will eventually let you drill down to see files in folders, but for now I'm just trying to get the directories to show up.
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<TreeView Name="DirectoryTree" HorizontalAlignment="Left" VerticalAlignment="Top" Width="270" Height="260">
This is the code I'm trying to use to populate the treeview
The bolded line is where I'm running into trouble- my Parent object does not contain an Items method. Suggestions? Am I going about this the completely wrong way?
private void Window_Loaded(object sender, RoutedEventArgs e)
TreeViewItem newChild = new TreeViewItem();
foreach (DriveInfo di in DriveInfo.GetDrives())
newChild.Header = di.Name;