Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding to header name in DataGrid

$
0
0

I am trying to display the full name of a column in a DataGrid in a ToolTip because they typically don't fit in the default view. I do that successfully for the cells with the following code:

<DataGrid Name="DG_Channels" x:FieldModifier="public" AlternatingRowBackground="#FFFFFFDE" ColumnWidth="*" IsReadOnly="True" CanUserResizeRows="False" SelectionMode="Single" HeadersVisibility="None" SelectionChanged="OnChannelsSelChgd"><DataGrid.CellStyle><Style TargetType="DataGridCell"><Setter Property="ToolTip" Value="{Binding Name}"/></Style></DataGrid.CellStyle></DataGrid>

The tooltip displays the exact same text as the cell content, it is useful becuase the cell is usually much narrower and the text is truncated in it; the tooltip displays the full text.

However, when I try to follow the same approach for the column headers, I can't figure how to bind to the header content:

<DataGrid Name="DG_ChanCals" MaxHeight="150" x:FieldModifier="public" AlternatingRowBackground="#FFFFFFDE" ColumnWidth="*" IsReadOnly="True" CanUserResizeRows="False" SelectionMode="Single" Grid.Row="1" AutoGeneratingColumn="ChanCalsAutoGenColumn"><DataGrid.ColumnHeaderStyle><Style TargetType="DataGridColumnHeader"><Setter Property="ToolTip" Value="HeaderBinding"/></Style></DataGrid.ColumnHeaderStyle></DataGrid>

Any idea what syntax I should use for the binding so that instead of the "HeaderBinding" string I get the actual content of the header?

Thanks.

Kamen


Currently using Visual Studio 2010 SP1, native C++ (Windows API) and C# (.Net, WPF), on Windows 7 64-bit; Mountain Time zone.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>