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
300
Highlight / select records programmatically
posted

Hi folks,

 

Here is what I am trying to do:

When the user clicks on one record containing data of Product 1, all other records with data from Product 1 should be selected / highlighted.

In my sample project I programmatically add the corresponding records to the datagrid.SelectedItems collection.

For a blink you can see, that the other records are selected aswell, but I want them to stay selected / highlighted.

 

I have added my test project. Thanks for any input in advance.

XamDataGridStyling.zip
Parents
  • 27093
    Verified Answer
    posted

    Hello,

    When activating a record the SelectedItemsChanging and SelectedItemsChanged events are raised and any changes to the this.myDataGrid.SelectedItems.Records collection also fire these two events and you end up in an infinite loop. What you can do is something like this in your myDataGrid_SelectedItemsChanged event:

     

                if (this.myDataGrid.SelectedItems.Records.Count == 1)

                {

                    this.myDataGrid.SelectedItems.Records.Clear();

                }

                else

                {

                    if (this.myDataGrid.SelectedItems.Records.Count == 0)

                    {

                        this.myDataGrid.SelectedItems.Records.AddRange(selRecs.ToArray());

                    }

                }

     

     

    Instead of doing it in HighlightRecords (in RecordActivating

     and RecordActivated), In order to control the event raising.

     

    Please let me know if you require any further assistance.

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support

     

Reply Children
No Data