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

How to use SfDataGrid.AddNewRowInitiating event in ViewModel

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.

3 Replies

SS Susmitha Sundar Syncfusion Team 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 

NG Nguyen August 3, 2019 07:37 AM UTC

Thank for your help, it is useful with me.

FP Farjana Parveen Ayubb Syncfusion Team 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 

Live Chat Icon For mobile
Up arrow icon