WPF DataGrid - Event for New Rows?

前端 未结 7 1936
梦谈多话
梦谈多话 2020-12-06 17:13

I\'m using the WPF DataGrid (.Net 3.5 SP 1 version from the Toolkit)

What event can I subscribe to, to detect when a new row is added?

7条回答
  •  我在风中等你
    2020-12-06 18:08

    The event you are looking for is DataGrid.AddingNewItem event. This event will allow you to configure the new object as you want it and then apply it to the NewItem property of the AddingNewItemEventArgs.

    Xaml:

            
    

    Code behind:

    private void GrdBallPenetrations_AddingNewItem(object sender, AddingNewItemEventArgs e)
        {
            e.NewItem = new BallPenetration
            {
                Id              = Guid.NewGuid(),
                CarriageWay     = CariageWayType.Plus,
                LaneNo          = 1,
                Position        = Positions.BetweenWheelTracks
            };
        }
    

提交回复
热议问题