locked
Code samples for WPF TreeView and ListView with similar Look and Behaviour to Win 7 Explorer Tree and Details View RRS feed

  • 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

All replies