This example illustrates how to add MVVM capabilities to the Master-Detail functionality. In this example we have created the MasterDetailMVVMHelper class that introduces the ExpandedMasterRowsSource attached property. This property is intended to be attached to GridControl and allows controlling details' expanded state via a collection in a view model.
Here is a sample XAML that illustrates how to attach this property to GridControl and make it bound to the ExpandedItems collection:
[XAML]<dxg:GridControlmy:MasterDetailMVVMHelper.ExpandedMasterRowsSource="{Binding ExpandedItems}"Name="gridControl1"ItemsSource="{Binding Data}">
Now, by adding a couple of data objects to the ExpandedItems collection, you can expand corresponding rows in GridControl:
[C#]ExpandedItems.Add(Data[1]);ExpandedItems.Add(Data[10]);
[VB.NET]ExpandedItems.Add(Data(1)) ExpandedItems.Add(Data(10))
An important note: The collection being bound to the ExpandedMasterRowsSource must be an implementation of the INotifyCollectionChanged interface, otherwise this functionality will not operate as expected.
Question Comments
Added By: Ipek Guven at: 6/26/2012 11:52:42 PM
This solution is not working with the latest native Master-Detail feature in Vol 12.1. Can you upgrade the solution or provide a new one for the latest release?
Thanks in advance.
Ipek
Ipek, you might want to reference the Grid.Extensions dll as well.
http://www.devexpress.com/Support/Center/p/Q383850.aspx
Is there any same example for winforms
thanks Neeraj
Hello Neeraj,
I have extracted your question to a separate ticket - How to obtain expanded rows when the Master-Detail functionality is used - and passed it to our WinForms team. That ticket is in our processing queue, and we will update it once we have any news.