0

我无法执行从 DataGrid 到剪贴板的复制操作。我想允许用户从 DataGrid 中选择一些单元格并将它们粘贴到他想要的任何地方。

当我尝试通过用鼠标单击网格中的单元格来选择它时,似乎没有任何反应。单元格/行不会更改为突出显示,并且复制 (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>
4

1 回答 1

1

该死。我现在喂得很傻。我在数据网格的顶部显示了一个图像(半透明)(为我们的日志提供水印)。当用户尝试行时,他实际上是在选择图像......

于 2012-02-12T09:22:30.033 回答