Answered by:
Code samples for WPF TreeView and ListView with similar Look and Behaviour to Win 7 Explorer Tree and Details View

Question
-
Hi,
I have implemented a set of entities using the composite design pattern using Entity Framework (i.e. entities exist within folders and folders can contain sub-folders).
I now wish to implement a WPF GUI (using the MVVM pattern) with a similar basic look and behaviour to the Windows Explorer in Win 7 to maintain these entities (i.e. CRUD operations). I currently have a GUI developed with Win Forms as per the screen below:I don't want to purchase a third party control as it seems that the standard WPF TreeView and ListView controls are flexible enough to implement similar look and behaviour.
I'm not wanting to provide all the features of Win 7 Explorer (of which there are a lot). For example, I don't require all the different Views available in Windows Explorer (e.g. Content, Tiles, List, Small icons, Medium icons...), just the Details view would be sufficient.
I found Josh Smith's article (http://www.codeproject.com/Articles/26288/Simplifying-the-WPF-TreeView-by-Using-the-ViewMode) an excellent introduction to using MVVM with the WPF TreeView (including lazy loading).
Another very good article I found by Lee Robie (http://www.codeproject.com/Articles/61316/Tuning-Up-The-TreeView-Part-1) which included CRUD operations in a TreeView.
Must haves in TreeView:
- CRUD operations (including in place editing of name in tree to rename a folder)
Must haves in ListView:
- CRUD operations (including in place editing of name in tree to rename an an item within a folder)
- multi-select and sorting.
Nice to haves:
- Similar color and styles to Windows Explorer (e.g. current item in the tree and list view)
- Drag and drop (within tree and list view and from list view to tree view and vice versa).
- Re-ordering of columns in list-view (choice of columns isn't required)I presume a ListView rather than a DataGrid is the way go as I don't require all entity attributes to be editable in place (just the name). Although one complication is that different entity folders contain different entity types hence the columns in the Details view needs to change based on which folder is selected. My understanding is that the DataGrid does include autogeneration of columns which in my case may be useful.
Any pointers to working code would be very much appreciated.
I am new to WPF hence would very much like to use WPF as it was designed to be used, and model my code on a fullsome example which use the relevant design patterns (e.g. MVVM, routed commands).
Thanks in advance,
Joel Gordon.Friday, June 22, 2012 1:54 AM
Answers
-
Hi Joel Gordon,
I think you need a TreeListView control to achieve this goal, you could download the sample code, and adapt it to your specific needs in your application:
http://www.codeproject.com/Articles/30721/WPF-TreeListView-Control
http://msdn.microsoft.com/en-us/library/ms771523(VS.90).aspx
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Sheldon _Xiao Friday, July 6, 2012 8:18 AM
Tuesday, June 26, 2012 7:03 AM
All replies
-
Hi Joel Gordon,
I think you need a TreeListView control to achieve this goal, you could download the sample code, and adapt it to your specific needs in your application:
http://www.codeproject.com/Articles/30721/WPF-TreeListView-Control
http://msdn.microsoft.com/en-us/library/ms771523(VS.90).aspx
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Sheldon _Xiao Friday, July 6, 2012 8:18 AM
Tuesday, June 26, 2012 7:03 AM -
Hi Joel Gordon,
I am marking your issue as "Answered", if you have new findings about your issue, please let me know.
Best regards,Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, July 6, 2012 8:18 AM