Для CSS3-совместимых браузеров есть white-space-collapsing:discard
: http://www.w3.org/TR/2010/WD-css3-text-20101005/#white-space -collapsing
Наконец мне удалось заставить его работать. Если я напрямую привязываю свойство к заголовку столбца, он не заполняет значение.
Мне приходилось делать следующее:
<DataGridTextColumn Binding="{Binding Name}">
<DataGridTextColumn.Header>
<TextBlock Text="{Binding DataContext.MyProp,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}}" />
</DataGridTextColumn.Header>
</DataGridTextColumn>
Вы можете получить доступ к родительскому datacontext, используя
Binding="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type DataGrid}}, Path=DataContext.ColumnName}"
Итак, чтобы добавить столбец, показывающий свойство A do
<DataGridTextColumn Header="Company" Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Company}"/>