I'm sure this is a simple question, but I can't seem to find the answer anywhere.
I have a WPF form with 2 XamDataGrids displaying a parent/child relationship (e.g. orders in the parent XamDataGrid and related order details in the child XamDataGrid). I can easily bind the parent to my view model, but i can't seem to find how to bind the DataSource of the second XamDataGrid to the ActiveDataItem of the first.
I would think it would be something like:
DataSource="{Binding OrdersXamDataGrid.ActiveDataItem.OrderDetails}"
That doesn't seem to work so I must be missing something. Any help would be appreciated.
Thanks,
Steve
Hello Steve,
Thank you for your post.
I am assuming that your OrdersXamDataGrid is the Name of your XamDataGrid. If this is the case, then this binding won't work, as you will be binding to the data context of your secondary grid, and I find it rather unlikely that your grid exists on that data context. If my assumption is correct, I would recommend that you bind using an ElementName binding instead. This binding could look like the following:
DataSource="{Binding ElementName=OrdersXamDataGrid, Path=ActiveDataItem.OrderDetails}"
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer