WPF: Master - detail view with two datagrids and in MVVM

Posted by EV on Stack Overflow See other posts from Stack Overflow or by EV
Published on 2010-04-24T19:28:31Z Indexed on 2010/04/24 19:33 UTC
Read the original article Hit count: 1338

Filed under:
|
|
|
|

Hi, I'm trying to write a master - detail control that consists of a master datagrid and the detail datagrid. My scenario was following - I used the SelectedItem and bound it to a property in ModelView. The problem is - the SelectedItem in ViewModel is never used, so I can't get the information which item is selected in a master datagrid and cannot fetch the data for thos selection.

The code is below:

<toolkit:DataGrid ItemsSource="{Binding}"  RowDetailsVisibilityMode="VisibleWhenSelected" SelectedItem="{Binding SelectedItemHandler, Mode=TwoWay}"></toolkit:DataGrid>

And in ViewModel

private CustomerObjects _selectedItem;    
public CustomerObjects SelectedItemHandler {
                get { return _selectedItem; }
                set
                {
                         OnPropertyChanged("SelectedItem");

                }

            }

The code in SelectedItemHandler is never used. What could be the problem? Should I use another approach to create master - detail in MVVM?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mvvm