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

4 posts, 0 answers
  1. Dean K.
    Dean K. avatar
    55 posts
    Member since:
    Aug 2011

    Posted 29 Aug 2014 Link to this post

    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.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dean K.
    Dean K. avatar
    55 posts
    Member since:
    Aug 2011

    Posted 01 Sep 2014 in reply to Dimitrina Link to this post

    No, I clearly stated that the VM is instantiated dynamically and explained why it must be instantiated that way.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Sep 2014 Link to this post

    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.
     
Back to Top