title: How can I change my treeview's visual to automatically display a SelectedItem?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2241367/wpf-treeview-how-to-scroll-so-expanded-branch-is-visible">WPF TreeView - How to scroll so expanded branch is visible</a>  </p>
  </blockquote>
  
  
  
  <p>I'm developing an application that utilizes the standard TreeView functionality in WPF. I've created a search function within the TreeView that will parse through the tree and locate a matching title (e.g. "Create" will work for finding a TreeViewItem titled "Create a Project:". If I press the "enter" key while the search textbox still has focus, it'll parse through the tree for the next possible TreeViewItem. The search functionality is inspired by the code found here at <a href="http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx" rel="nofollow noreferrer">Josh Smith's TreeView Article</a>, but modified slightly to work within the resources of my application and its nodes (the trees generated are dynamic, depending on the files imported in the application, and I obviously have my own Object classes). </p>
  
  <p>When I tried to look up this issue, I found a million and one search hits for how to set the SelectedItem for the TreeView (which I'm not having an issue with), but I couldn't find anything specifically for my problem which is this: Every time I do a search, the tree will find the SelectedItem (if it exists), and call IsExpanded = true to all the elements recursively up to the root of the tree. But sometimes the element discovered is outside of the visual frame of the TreeView (I have scrollbars set to auto, so when the tree grows too large horizontally or vertically, scroll bars are enabled). The SelectedItem changes appropriately, but I have to scroll down the TreeView in order to find where my match was made. What I'm hoping to do is fire an event that will detect when the SelectedItem is changed, and then force the Visual of the TreeView to show the selected item at some point within its visible frame (so it's never out of visibility if found), but I'm not sure how exactly to do this (my experience with WPF is limited to the last month or so I've spent developing this application, so I'm still new to the language and picking things up as I go along).</p>
  
  <p>Are there any solutions for this? I can provide code if desired, but I'm just looking for somebody to point me in the right direction on how to change the visible region of my TreeView item.</p>