How to bind DataGridTemplateColumn.Visibility to a property outside of DataGrid.ItemsSource?

前端 未结 2 554
旧巷少年郎
旧巷少年郎 2021-01-11 09:13

I need to bind the Visibility of a DataGridTemplateColumn to a property outside of the DataGrid.ItemsSource,because i need to bind thi

2条回答
  •  时光取名叫无心
    2021-01-11 09:49

    Your binding is correct, but it won't work with DataGridTemplateColumn directly because it's not in the visual tree. So it's not inherting DataContext.

    You need to bind the DataGridTemplateColumn from code behind. Here is a demo that shows a way of doing it.

提交回复
热议问题