开发者

.NET - Doesn't exist an event named RowEditEnded or something for datagrid in WPF?

开发者 https://www.devze.com 2023-01-24 18:13 出处:网络
I am doing this: private void dataGrid1_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)

I am doing this:

private void dataGrid1_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) {

        Person newPerson = ((Person)dataGrid1.SelectedItem);
        foreach (Person person in lista)
        {
            if(person.Id == newPerson.Id)
            {
                person.Name = newPerson.Name;
                person.Salary = newPerson.Salary;
            }
        }


    }

but when I press "enter" after editing a row, the name isnt changed at newPerson object. I think it's because this event is "Ending", and not "ended".

I already binded the thing in mode twoWay. Like 开发者_Python百科this:

<DataGridTextColumn Binding="{Binding Name, Mode=TwoWay}" Header="Name"></DataGridTextColumn>


The event name is RowEditEnding. Just make sure the event handler name in your XAML matches the name of the handler in your code behind. That being said, you would get an exception if you didn't have the names matching up.

0

精彩评论

暂无评论...
验证码 换一张
取 消