Click here to Skip to main content
15,896,153 members
Articles / Desktop Programming / WPF
Alternative
Article

WPF Folder Browser

Rate me:
Please Sign up or sign in to vote.
4.33/5 (2 votes)
26 Apr 2012CPOL1 min read 26.1K   1.3K   7   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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 3 Pin
Claire Streb15-May-12 10:43
Claire Streb15-May-12 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.