DataGridからクリップボードへのコピー操作を実行できません。私は、ユーザーがDataGridからいくつかのセルを選択し、必要な場所に貼り付けることを許可します。DataGridからコピー&ペースト - ctrl Cのようにコピーできない
グリッド内のセルをマウスでクリックして選択しようとすると、何も表示されません。セル/行はハイライト表示に変わらず、コピー(Ctrl + C)は何もしません。
<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>
.Netについてはよくわかりませんが、異なるセルをコピーしている場合、コンピュータは内部的にどのように表現していますか? – Shaheer
@Shaheer私は時間分野については本当に気にしません。すべてのデータを文字列として取得したり、テキスト列からデータを取得することができれば問題ありません。 – OSH
次に、イベントハンドラのチェックでCtrl + Cの組み合わせのイベントをバインドすることをお勧めします。セルが選択されている場合はその値を文字列にコンマで区切り、その文字列をクリップボードにコピーします。 (私は.Netはそれを行う方法があると思います)。 – Shaheer