Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

WPF Folder Browser

0.00/5 (No votes)
26 Apr 2012 1  
This is an alternative for WPF Folder Browser

Introduction

This version of the WPF Folder Browser introduces new basic functionality.

It offers

  • Automatic treeview folder opening and scrolling when the SelectedFolder is changed programmatically or via user input in the text box.
  • Update of SelectedFolder on enterkey down.  
  • Selection on double click. 

Background 

Sean Ireson liked the original solution so much that he went through the hassle of improving it and offer the code to the original poster for updating. Years later he was kind enough to email me his new code base to save me some time. Now I've made another tiny update which I think makes it worth to reshare.

Using the code

The changes to the original code done by Sean:

  • Introduction of the TreeViewItemBehaviour class introducing the DependencyProperty IsBroughtIntoViewWhenSelected
  • Modification to the BrowserViewModel by introducing the OnSelectedFolderChanged and Expand functions.
  • Addition of a text_box click event that selects and closes the form on double click on either text or treeview node.
  • I added the InputBindingManager class blatantly stolen from this StackOverflow answer by Samuel Jack. This enables the textbox to update the binding on enter key down events by creating an attached behaviour to the textbox in the XAML code. 

Points of Interest

The Attached Behavior is quite practical for use on templated controls.

History

Nothing so far.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here