Get the parent listview from a gridview object

ぐ巨炮叔叔 提交于 2019-12-22 10:41:16

问题


In the code-behind of a WPF application I have a variable containing a GridView. I know for sure that this GridView is the View of a ListView. Is there any way to get a reference to that ListView?

Thanks


回答1:


http://www.hardcodet.net/2008/02/find-wpf-parent

We've been using these helper classes for a while to find visual elements in the visual tree. In this case, you'd just want to use the method and it will hunt down the visual ancestor.

TryFindParent<ListView>(yourGridView);


来源:https://stackoverflow.com/questions/1420742/get-the-parent-listview-from-a-gridview-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!