2

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?

  • 2
    Basically a duplicate of [this](http://stackoverflow.com/questions/6857780/how-to-hide-wpf-datagrid-columns-depending-on-a-property/6858917), which trips people up all the time... – H.B. May 20 '13 at 16:53
  • wow... thats it! if you care, you might want to post your that as an answer, i'd mark it –  May 20 '13 at 17:58
  • 1
    I don't know if that serves much of a purpose, it would be great if there were one single canonical question and questions such as yours could be marked as duplicate. (On that note you could flag your question to have it closed as duplicate explicitly and just upvote my answer in the linked question) – H.B. May 20 '13 at 18:00
  • sounds fair, i did as asked, however i would like to note that i did a fair amount of research before i posted, but i didn't stumble over that particular question. –  May 20 '13 at 18:54
  • There are quite a lot of them, the problem is as i said that none are very generic (which would be something like "How to bind DataGrid column properties?"), maybe i will make one at some point... – H.B. May 20 '13 at 19:05

0 Answers0