Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
Event Raised when new Row is Added to Grid?
posted

Hi,

I have an Observable Collection which is the Datasource of the xamdatagrid.

On receiving a new message on the wire, I add the an Item to the Observable collection.

The user can set filters on the grid so that not all items added are displayed on the grid.

User also needs me to alert when a new row gets displayed in the grid(meet the filter criteria).

To do the above I cannot Alert when I am adding to the collection but need to Alert only when the Item gets added to the grid.

Which event should I tap into if I need to know that Data Record has been added to the grid?

Parents
  • 28407
    Verified Answer
    posted

     HI,

     You can wire up the XamDataGrid's Records CollectionChanged and check if the DataRecord is filtered out.

     Here is the code snippets.

    xgrid1.Records.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Records_CollectionChanged);     

     

    void Records_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

            {

               // throw new NotImplementedException();

                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)

                {

                     for (int i = 0; i < e.NewItems.Count ; i++)

     

                    {

                        DataRecord dr = e.NewItems[i] as DataRecord;

                        if ((dr.IsFilteredOut == false)|| (dr.IsFilteredOut == null))

                        {

                            MessageBox.Show(dr.Cells[0].ToString());

                        }

                    }

                }

                    

               

            }

     

Reply Children
No Data