1
votes

I'm using the datagrid from the WPF Toolkit for 3.5.

I have a need to TextWrap one of my columns in this grid so have embedded a TextBlock in this column.

The issue I have now is that when I copy the grids content into excel (Ctrl A, Ctrl C) this column is blank.

Any help on resolving this would be much appreciated. Below is my XAML for the grid.

<tk:DataGrid Name="dgDataGrid" Margin="3" AutoGenerateColumns="False" HeadersVisibility="All" 
                         ClipboardCopyMode="IncludeHeader" SnapsToDevicePixels="True" 
                         CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True"
                         SelectionMode="Extended" SelectionUnit="Cell">
  <tk:DataGrid.Columns>
    <tk:DataGridTextColumn Binding="{Binding ID}" Header="Message ID" Visibility="Hidden" FontWeight="Black" />
    <tk:DataGridTextColumn Binding="{Binding UserInitials}" Header="User" Width="Auto" />
    <tk:DataGridTextColumn Binding="{Binding EntryDate}" Header="Time Stamp" Width="Auto" />
    <tk:DataGridTemplateColumn Header="Message" Width="*">
      <tk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <TextBlock Margin="0" Text="{Binding Message}" TextWrapping="Wrap"/>
        </DataTemplate>
      </tk:DataGridTemplateColumn.CellTemplate>
    </tk:DataGridTemplateColumn>
  </tk:DataGrid.Columns>
</tk:DataGrid>
1

1 Answers

2
votes

Set the ClipboardContentBinding property on the DataGridTemplateColumn.