TextChanged / LostFocus / etc .. event for DataGridTextColumn

I have a list of objects attached to DataGridon a WPF page, and I want to add an object immediately after the current one, if the value entered in a specific column is less than a certain number.

<my:DataGridTextColumn Binding="{Binding Path=Hours}"/>

I can’t understand for life how to associate an event with a base one TextBox. Various sites cite the ability to do this, but none of them provide related code. At the moment I am using DataGridTemplateColumnc TextBoxinside it, but it seems to me that I cannot get the current line with this solution.

+3
source share
2 answers

CellEditEnding .

this.TheGrid.CellEditEnding += new EventHandler<DataGridCellEditEndingEventArgs>(TheGrid_CellEditEnding);

Dispatcher , .

private void TheGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
    Dispatcher.BeginInvoke(new Action(this.CellEdited));
}

DataGridCellEditEndingEventArgs , , TextBox.

, , ( ).

+3

:

<sdk:DataGrid ItemsSource="{Binding Collection}" CellEditEnded="DataGrid_CellEditEnded" RowEditEnded="DataGrid_RowEditEnded">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTextColumn Binding="{Binding Path=Hours}" Width="Auto" />
    </sdk:DataGrid.Columns>
</sdk:DataGrid>
0

Source: https://habr.com/ru/post/1729091/


All Articles