I can't perform copy operations from my DataGrid to the clipboard. I want to allow the user to select some cells from the DataGrid and paste them wherever he wants.
When I try to select a cell in the grid by clicking on it with the mouse, nothing appears to happen. The cell/row does not change to highlighted, and copy (ctrl C) doesn't do anything.
Here is my DataGrid:
<Grid Margin="2,2,2,2" Background="LightGray">
<!-- Log -->
<Label Name="activityLogLabel"
Height="28"
Margin="15,5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Activity log" />
<Grid Width="500"
Height="482"
Margin="15,25,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="White">
<DataGrid x:Name="log"
MaxHeight="Infinity"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
ClipboardCopyMode="ExcludeHeader"
ClipToBounds="True"
DataContext="{StaticResource LogViewModel}"
HeadersVisibility="None"
IsEnabled="true"
IsManipulationEnabled="True"
IsReadOnly="True"
ItemsSource="{Binding Path=LogData}"
RowHeight="NaN"
SelectionMode="Extended"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Time, Mode=OneWay}" CanUserResize="False" />
<DataGridTextColumn Binding="{Binding Text, Mode=OneWay}" CanUserResize="False">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{Binding LogLevel, Mode=OneWay, Converter={StaticResource LogLevelConverter}, ConverterParameter=.}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>