Home > Back-end >  WPF copying datagrid converted cell values copies empty string
WPF copying datagrid converted cell values copies empty string

Time:06-24

I am not sure if it is bug, or feature, but I am unable to copy Converted value via binding.

I have columns in datagrid:

<DataGridTextColumn Binding="{Binding Value.Item}" Header="Položka" />
<DataGridTextColumn Binding="{Binding Value.Quantity}" Header="Množství" />
<DataGridTextColumn Binding="{Binding Value.PrimaryUomCode}" Header="UOM" />
<DataGridTextColumn Binding="{Binding Value.InventoryItemId, Converter={StaticResource InventoryItemIdToItemDescription}, IsAsync=True}" Header="Popis" />

if I select cells like this:

enter image description here

Then only this get copied:

184 pc  
50  pc  
7   pc  

I was unable to solve it, nor find anyone with the same issue.

Does anyone know what is wrong in here?

Just for reference, those are my DG properties:

<DataGrid
     x:Name="Stocks_DataGrid"
     AutoGenerateColumns="False"
     IsReadOnly="True"
     SelectionUnit="Cell">

CodePudding user response:

Use the ClipboardContentBinding property to bind to the same value:

<DataGridTextColumn Binding="{Binding InventoryItemId, Converter={StaticResource InventoryItemIdToItemDescription}}" 
                    Header="Popis"
                    ClipboardContentBinding="{Binding InventoryItemId, Converter={StaticResource InventoryItemIdToItemDescription}}"/>
  • Related