This is a migrated thread and some comments may be shown as answers.

How to set Child GridView DataContext to underlying VM, not the selected item of the parent GridView?

3 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 29 Aug 2014, 04:23 PM
By default the DataContext of a child GridView is the selected item of the parent GridView. How would I change this so that the DataContext of the child GridView is the ViewModel of the containing UserControl which is also the DataContext of the parent GridView?

It is important to note that this VM is dynamically instantiated in code and not in XAML of the UserControl because this UserControl is one of several UserContorls which are used as dynamic Content of an area of a parent Window.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Sep 2014, 07:23 AM
Hi,

You can try defining the ViewModel as a StaticResource and then set it as a Source for the Binding of child RadGridView. You can also check the Binding.Source Property as a reference.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Dean
Top achievements
Rank 1
answered on 01 Sep 2014, 09:40 PM
No, I clearly stated that the VM is instantiated dynamically and explained why it must be instantiated that way.
0
Dimitrina
Telerik team
answered on 02 Sep 2014, 11:04 AM
Hello,

I apologize for this. You can do the same in code. The point is that you need to specify a valid Source for the Binding.

If this does not help, may I ask you to open a new support ticket and attach a demo project to illustrate your implementation there? That way I will be able to advise further.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Dean
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Dean
Top achievements
Rank 1
Share this question
or