:
<DataGrid x:Name="dg" SelectionUnit="FullRow">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="dg_PreviewMouseLeftButtonDown" />
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding}" />
<DataGridTextColumn Binding="{Binding}">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="IsEnabled" Value="False" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
private void dg_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DataGridRow row = sender as DataGridRow;
dg.SelectedItem = row.DataContext;
}
出典
2017-05-29 15:00:41
mm8
はい、それは可能です。 – Karolis
@ mm8:はい、完璧に、ありがとうございます。 –
@カロリス:ええ、本当に便利な答え... –