3

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) ?

Tomer
  • 4,382
  • 5
  • 38
  • 48
  • Is it the problem with binding like its not hitting or you are just setting it to true or false. You might need a Converter for that. – Nivid Dholakia Oct 31 '11 at 15:03
  • Does this answer your question? [Binding Visibility for DataGridColumn in WPF](https://stackoverflow.com/questions/22073740/binding-visibility-for-datagridcolumn-in-wpf) – Martin Liversage Nov 02 '21 at 09:18

1 Answers1

3

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...

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
Tomer
  • 4,382
  • 5
  • 38
  • 48