TreeViewMultiSelect updates – new sourceforge project

Update 2007-10-26: I think I’ve fixed it now. Note I haven’t properly implemented SelectItem() yet. I also want to do a better test control in the ControlsTester application for the tree view.

Update 2007-10-25: Yeah um….there’s some bugs. The code is pretty messy and I only looked at it quickly and it seems my fix broke something. I’ll have another look tomorrow.

Note: I’ve looked over the tree view code I wrote a while back and it’s not very robust, so there’s probably some problems. E.g. you can’t select sub nodes programatically. Still here’s the details:

I’ve done some updates to my TreeViewMultiSelect control. It’s now part of a sourceforge repository located here:

https://stewienmisc.svn.sourceforge.net/svnroot/stewienmisc/SourceCode

The specific files TreeViewMultiSelect and TreeViewItemMultiSelect are here:

https://stewienmisc.svn.sourceforge.net/svnroot/stewienmisc/SourceCode/WPF/Controls/

and there is a test control called TreeViewTester located here:

https://stewienmisc.svn.sourceforge.net/svnroot/stewienmisc/SourceCode/WPF/ControlsTest/

I haven’t done a release package of everything, but you can checkout using Subversion from this directory:

https://stewienmisc.svn.sourceforge.net/svnroot/stewienmisc/

Then in the SourceCode directory there is a Visual Studio 2005 solution. Run the Stewien.WPF.ControlsTest app and on the last tab is a quick and dirty app to play around with the tree view control.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to TreeViewMultiSelect updates – new sourceforge project

  1. Joachim says:

    thanks! I searched so long for this.Just one question: In my project, I\’m filling the treeview with "Themes", which have a collection of "Facts" . the Datacontext of some items is a Fact, now i need some facts to be invisible (visibility.collapsed, It has to be possible to set this to visible later on by selecting them in another list) . Is there a way to iterate over al the treeviewitems and search an individual TreeViewItemMultiSelect, so I can check it\’s datacontext ?thanks in advanceJoachim

  2. Matt says:

    Thanks John for making your code available. Yours is the only WPF TreeView multi-selection solution out of many online that actually worked. Cheers!

    • Peter says:

      Thanks, realy good solution.
      That part with using dictionary itemToTreeViewItem where is comment:
      // Not real happy with this solution.
      can be replaced with
      public void DeselectItem(object itemToDeselect)
      {
      TreeViewItemMultiSelect treeViewItem = (TreeViewItemMultiSelect)(this.ItemContainerGenerator.ContainerFromItem(itemToDeselect));
      if (treeViewItem != null)
      {
      // TreeViewItemMultiSelect treeViewItem = itemToTreeViewItem[itemToDeselect]; //not needed
      treeViewItem.IsSelected = false;
      if (selectedTreeViewItems.Contains(treeViewItem))
      {
      selectedTreeViewItems.Remove(treeViewItem);
      }
      }
      }

      so you don’t need
      private Dictionary itemToTreeViewItem;
      any more

  3. Pingback: WPF TreeView multi select | John Stewien's Road To Somewhere Else

Leave a comment