title: WPF MVVM TreeView SelectedItem
body: <p>This cannot be this difficult. The TreeView in WPF doesn't allow you to set the SelectedItem, saying that the property is ReadOnly. I have the TreeView populating, even updating when it's databound collection changes.</p>
  
  <p>I just need to know what item is selected. I am using MVVM, so there is no codebehind or variable to reference the treeview by. <a href="https://stackoverflow.com/questions/1238304/c-wpf-get-selecteditem-from-treeview">This is the only solution</a> I have found, but it is an obvious hack, it creates another element in XAML that uses ElementName binding to set itself to the treeviews selected item, which you must then bind your Viewmodel too. <a href="https://stackoverflow.com/questions/6308817/wpf-treeview-selecteditem-databinding">Several</a> other <a href="http://www.telerik.com/community/forums/wpf/treeview/selecteditem-bindable-in-mvvm.aspx" rel="noreferrer">questions</a> are asked about this, but no other working solutions are given.</p>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/1000040/selecteditem-in-a-wpf-treeview">this question</a>, but using the answer given gives me compile errors, for some reason I cannot add a reference to the blend sdk System.Windows.Interactivity to my project. It says "unknown error system.windows has not been preloaded" and I haven't yet figured out how to get past that.</p>
  
  <p>For Bonus Points: why the hell did Microsoft make this element's SelectedItem property ReadOnly?</p>