Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't use just the ItemID as a dependency property but the item itself. The following scenario should fulfill your requirements:</p> <p>Assume that CItem is the type of one record in your master/detail view. In the View that hosts your master and detail controls, use a view model that exposes a <code>List&lt;CItem&gt;</code> or if you dynamically want to add/remove items an <code>ObservableCollection&lt;CItem&gt;</code> which you set as the binding target for the <code>ItemsSource</code> of your master list. In addition, create a dependency property "SelectedObject" of type CItem in the view model. In the master list for SelectedItem create a two way binding to that "SelectedObject" property. In the details view just also bind to properties of "SelectedObject" like</p> <pre><code>&lt;TextBox Text="{Binding SelectedObject.MyProperty, Mode=TwoWay}" /&gt; </code></pre> <p>Now when the user in the master view selects a different record the SelectedObject property gets updated and due to that all detail bindings on that also will get an update.</p> <p>Edit: So if you need additional logic, think about using a callback funktion when the value of the dependency property ItemID changes. Use the <a href="http://msdn.microsoft.com/en-us/library/system.windows.propertymetadata.aspx" rel="nofollow">PropertyMetadata </a> with the <a href="http://msdn.microsoft.com/en-us/library/ms557327.aspx" rel="nofollow">PropertyChangedCallback constructor</a> when registering the dependency property. The callback function is called each time when the value of the dependency property changes. In this callback function you can trigger the additional logic you mentioned for loading/preparing the item for the details view.</p>
    singulars
    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.
 

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