Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate property on view model without code behind?
    primarykey
    data
    text
    <p>I'm using a TreeView inside a Combobox control (from <a href="http://blogs.telerik.com/valerihristov/posts/09-08-27/treeview_in_combobox_take_3_silverlight_3_wpf_and_radcontrols.aspx" rel="nofollow noreferrer">here</a>). I have a ViewModel object that is the DataContext of my window.</p> <p>What I would like to have happen is when the selected item in the treeview/combobox changes I want a property on my ViewModel to be updated with that selected item. Ideally I'd like to be able to do this completely in xaml but I can't quite figure out how to do it.</p> <p>The control has a "SelectedTreeViewItem" dependency property so basically I want to bind that property to a dependency property on my ViewModel object, but I don't know what exactly I need to do it (Trigger? EventTrigger?). The binding only has to be one way as I just want my view model's property to reflect what's currently selected in the control; I don't need to change the control's currectly selected item from my view model. I'm still pretty new to WPF.</p> <p>Here's the code for my control attempting to bind the SelectedTreeViewItem property to a property on my view model. It doesn't work, the property on my view model is always null.</p> <pre><code> &lt;local:TreeViewCombo x:Name="encounterCodeSelector" ItemsSource="{Binding Path=EncounterCodes}" ItemTemplate="{StaticResource EncounterCodesTemplate}" Style="{StaticResource TreeViewInComboBox}" SelectedTreeViewItem="{Binding Path=SelectedEncounterCode, Mode=OneWay}" Canvas.Left="171" Canvas.Top="377" Width="456"&gt; &lt;/local:TreeViewCombo&gt; </code></pre> <p>Edit:</p> <p>Changing the mode from "OneWay" to "OneWayToSource" worked.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload