-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDirectoryTreeView.xaml.cs
37 lines (34 loc) · 1.11 KB
/
DirectoryTreeView.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.ComponentModel;
using System.Windows.Controls;
using WpfDirectoryTreeView.DataAccess;
namespace WpfDirectoryTreeView
{
/// <summary>
/// Interaction logic for DirectoryTreeViewControl.xaml
/// </summary>
public partial class DirectoryTreeViewControl : UserControl
{
// Create list for directories and files.
private ItemProvider _itemProvider;
/// <summary>
/// Initialise gui and item provider, then attaches method to reload tree view.
/// </summary>
public DirectoryTreeViewControl()
{
InitializeComponent();
_itemProvider = new ItemProvider();
_itemProvider.PropertyChanged += populateTreeView;
}
/// <summary>
/// Load and display directory and file list.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void populateTreeView(object sender, PropertyChangedEventArgs e)
{
var items = _itemProvider.GetItems(e.PropertyName);
DataContext = items;
}
}
}