Demo
UI
TreeView
- TreeView control provides a way to display information in a hierarchical structure by using collapsible nodes.
Folder_Expanded
define what should do when tree folder expanded.
TreeViewItem
- a class for a TreeView child.
- Header : Text of tree item
- Tag : identifier of tree item
Style
- Styles can be defined in several different scopes, depending on where and how you want to use them, and you can even restrict styles to only be used on controls where you explicitly want it.
- Using the
Resources
section of a control, you can target child controls of this control (and child controls of those child controls and so on). - By setting the
x:Key
property on a style, you are telling WPF that you only want to use this style when you explicitly reference it on a specific control.
Setter
- Set something what you want in style
Image
- Image control will allow you to display images inside your applications.
- Using the
Source
property, you can add resource files to your project.
Value Convert
IValueConverter
- Provides a way to apply custom logic to a binding.
- When you use image resources on csharp code, you should change image
Build Action
toResource
and add$"pack://application,,,/"
MVVM
- M : A Model is responsible for exposing data in a way that is easily consumable by WPF. It must implement INotifyPropertyChanged and/or INotifyCollectionChanged as appropriate.
- V : A View is defined in XAML and should not have any logic in the code-behind. It binds to the view-model by only using data binding.
- VM : A ViewModel is a model for a view in the application or we can say as abstraction of the view. It exposes data relevant to the view and exposes the behaviors for the views, usually with Commands.
- It is based on the Model-view-controller pattern (MVC), and is targeted at modern UI development platforms (WPF and Silverlight) in which there is a UX developer who has different requirements than a more “traditional” developer.
Model
- DirectoryItem.cs
View
- MainWindow.xaml
ViewModel
- DirectoryStructureViewModel.cs
- DirectoryItemViewModel.cs