We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use SfDataGrid.AddNewRowInitiating event in ViewModel

Thread ID:





146120 Jul 21,2019 02:05 PM UTC Aug 5,2019 04:53 AM UTC WPF 3
Tags: SfDataGrid
Asked On July 21, 2019 02:05 PM UTC

i need custom SfDataGrid.AddNewRowInitiating event, but if i use it in code behind, it ok, but if i need use that event in ViewModel, can help me how to do that thanks.

Susmitha Sundar [Syncfusion]
Replied On July 22, 2019 07:52 PM UTC

Hi Nguyen, 

Thank you for using Syncfusion controls. 

We have analyzed your query”How to access the AddNewRowInitiating event in ViewModel”. You can achieve this by following code snippet. 
private SfDataGrid dataGrid; 
        public SfDataGrid DataGrid 
            get { return dataGrid; } 
            set { dataGrid = value; } 
public ViewModel() 
            orderCollection = new ObservableCollection<OrderInfo>(); 
            OrderInfoCollection = GenerateOrders1(); 
                new Action(() => 
                    DataGrid = Application.Current.MainWindow.FindName("grid") as SfDataGrid; 
                    DataGrid.AddNewRowInitiating += DataGrid_AddNewRowInitiating; 
private void DataGrid_AddNewRowInitiating(object sender, AddNewRowInitiatingEventArgs e) 
            //To Do 

Susmitha S 

Replied On August 3, 2019 07:37 AM UTC

Thank for your help, it is useful with me.

Farjana Parveen Ayubb [Syncfusion]
Replied On August 5, 2019 04:53 AM UTC

Hi Nguyen, 
Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Farjana Parveen A 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon