0

在我的程序中,我有DataGrid4 个不同的列。I would like to make it so that, in one of the columns, when a cell is selected for editing, I am able to change the content of that cell programmatically. 例如,在编辑时,string所选单元格中的当前值可能会更改为"selected"。我浏览了这里DataGridCell的课程,并没有真正找到任何可以检测到单元格编辑的内容。如果 xaml 中的每个都有一些“cellClick”事件,那就太好了。我如何实现这种类型的处理程序?DataGridTextColumn

我的 xaml DataGrid

<DataGrid ItemsSource="{Binding SysModel.SystemCollection}" MinColumnWidth="50" ColumnHeaderStyle="{StaticResource HeaderStyle}" RowStyle="{StaticResource RowStyleWithAlternation}" CellStyle="{StaticResource CenterCellStyle}"
          RowHeaderWidth="0" AlternationCount="2" GridLinesVisibility="Horizontal" SelectionUnit="Cell" CanUserAddRows="False" AutoGenerateColumns="False" Height="471" Name="dataGrid1" Width="468" Canvas.Left="40" Canvas.Top="17">
    <DataGrid.Columns>
        <DataGridTextColumn Header="{DynamicResource cart}" Width="Auto" IsReadOnly="True" Binding="{Binding cartNum}" />
        <DataGridTextColumn Header="{DynamicResource ipAddress}" Width="100" IsReadOnly="False" Binding="{Binding ipAddress}" />
        <DataGridTextColumn Header="{DynamicResource portNumber}" Width="70" IsReadOnly="False" Binding="{Binding PortNumber}" />
        <!-- **This is the column that contains the cells I want to have this event for** -->
        <DataGridTextColumn Header="{DynamicResource configuration}" Width="*" IsReadOnly="False" Binding="{Binding Configuration}" />
        </DataGrid.Columns>
        <DataGrid.Resources>
            <SolidColorBrush Color="#726AA5" x:Key="{x:Static SystemColors.HighlightBrushKey}" />
        </DataGrid.Resources>
</DataGrid>
4

1 回答 1

0

DataGridCell选择时触发Selected事件。我想在用户编辑它之前,它应该被选中。

来源:DataGridCell 事件

于 2014-12-18T19:53:30.513 回答