开发者

WPF Toolkit Datagrid Copying Grid

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" />
开发者_如何学C    <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>


Set the ClipboardContentBinding property on the DataGridTemplateColumn.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜