How to access data from another datatemplate in wpf?

后端 未结 2 810
野的像风
野的像风 2021-01-28 20:45

I have 2 Datatemplates. One contain a grid , second one contain a button. I need to send command parameters of button as selected grid items.

How can i do this ?

<
相关标签:
2条回答
  • 2021-01-28 21:29

    You could try to use a Binding with the RelativeSource property set to the FindAncestor mode and looking for a DataGrid object. However, I am not sure whether it will work in your scenario because I do not know how these DataTemplates are related to each other. Is the second DataTemplate used for the items in the DataGrid?!

    Somehow, your design feels strange to me. Are you sure that you need DataTemplates in both cases? What exactly do you want to achieve?

    0 讨论(0)
  • 2021-01-28 21:34

    Take a look at this article. Maybe it'll help you:

    http://www.dev102.com/2008/08/07/how-to-access-a-wpf-control-which-is-located-in-a-datatemplate/

    0 讨论(0)
提交回复
热议问题