Bind DataGridTemplateColumn Visibility

和自甴很熟 提交于 2019-12-01 07:40:37

问题


I am trying to bind the visibility of a column in a datagrid to a boolean DependencyProperty in the ViewModel (Set as data context of the View - UserControl in this case). For some reason (I don't seem to understand) it just doesn't work.

After looking here I found out that the datagridtemplate (and any other template) is not part of the visual tree. So I can't bind to it.

Any simple solution to the problem (without breaking the MVVM pattern of course) ?


回答1:


Found the solution here:
http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/
For future quenstions...



来源:https://stackoverflow.com/questions/7955318/bind-datagridtemplatecolumn-visibility

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