WPF DataGridTemplateColumn Header binding not working

依然范特西╮ 提交于 2020-01-15 03:21:06

问题


I am using the DataGrid with some manually created DataGridTemplateColumns. Here is a code snippet of that in work:

<DataGrid ItemsSource="{Binding Projects, Mode=OneWay}" 
          SelectedItem="{Binding SelectedProject}"
      SelectionMode="Single"
      CanUserSortColumns="True"
      RowBackground="Transparent">
    <DataGrid.Columns>
            <DataGridTemplateColumn Header="Art" Width="60" />
    <DataGrid.Columns>
<DataGrid>

Everything works just fine, data is loaded and my column is displayed as expected. However, when i try to bind the Header to any property of my ViewModel, no text is displayed in the header.

I already tried to replace the headertemplate with a really simple datatemplate with a textbox, but it seems that the header binding just won't work.

To clarify, i am not binding to the viewmodels in the list that is displayed in the datagrid, but to the viewmodel of my window. It works everywhere else on the window, but not with DataGrid.

What am i doing wrong?

来源:https://stackoverflow.com/questions/16654305/wpf-datagridtemplatecolumn-header-binding-not-working

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