我正在编辑datagrid中的一个文本单元格,我想获取datagrid单元格文本中的所选文本。是否有针对它的事件?目标是找出所选文本的含义,并显示带有该含义的工具提示。请参见图片
enter image description here
<DataGrid x:Name="dgMeanings" Grid.Row="5" FontSize="16" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RowEditEnding="dgMeanings_RowEditEnding" PreviewKeyDown="dgMeanings_PreviewKeyDown" AddingNewItem="dgMeanings_AddingNewItem" Background="{Binding ButtonBackColor}" Foreground="{Binding TextForeColor}" SelectionChanged="txt_SelectionChanged" CellEditEnding="dgMeanings_CellEditEnding" >
<DataGrid.Columns>
<DataGridTextColumn Header="#" Binding="{Binding IORDER,UpdateSourceTrigger=LostFocus}" Width="30"/>
<DataGridTextColumn Header="LEVEL" Binding="{Binding LEVEL,UpdateSourceTrigger=LostFocus}" Width="50"/>
<DataGridTextColumn Header="AS" Binding="{Binding TYPE ,UpdateSourceTrigger=LostFocus}" Width="60" />
<DataGridTextColumn Header="MEANING" Binding="{Binding MEANING ,UpdateSourceTrigger=LostFocus}" Width="400" />
<DataGridTextColumn Header="TRANSLATION" Binding="{Binding TRANSLATION ,UpdateSourceTrigger=LostFocus}" Width="150" />
<DataGridTextColumn Header="EXAMPLE" Binding="{Binding EXAMPLE,UpdateSourceTrigger=LostFocus}" Width="400"/>
<DataGridTextColumn Header="EXAMPLE TRANSLATION" Binding="{Binding EXAMPLE_TRANSLATION,UpdateSourceTrigger=LostFocus}" Width="400"/>
</DataGrid.Columns >
<DataGrid.Resources>
<Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Black" />
</Style>
</DataGrid.Resources>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="{Binding LabelForeColor}"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
1条答案
按热度按时间hgqdbh6s1#
C#程式码
XAML格式
将
SelectedCellsChanged="dgMeanings_Clicked"
添加到DataGrid
定义中如果此操作未按预期运行或您有任何疑问,请告诉我