bind to a property in the parent control

前端 未结 3 1598
一向
一向 2020-12-31 05:08

i have the following case:

Window
  |_Grid
      |_ListView (MainProductGrid)
           |_View
               |_GridView
                    |_GridViewColum         


        
3条回答
  •  情书的邮戳
    2020-12-31 05:35

    Well since you're in the context of a DataTemplate you cannot access the property via TemplatedParent mode, at least in your case. It refers to the element to which the template (in which the data-bound element exists) is applied. [...] Link I'm not sure, that it can be used in a DataTemplate because I've only seen it in ControlTemplates, but since the docs are not telling otherwise...

    What you can do is to try find the Ancestor. E.g.

    I didn't used in DataTemplates yet, so no warranty.

提交回复
热议问题