is there any event which is raised when mouse is click on a record or cell? I am familiar with record activating/activated event, but it does not solve my purpose. I am looking for a mouse event.
I used PreviewMouseDown event as below, but does not help when I mouse click on deactive records.
protected internal virtual void LookupGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) { DependencyObject source = e.OriginalSource as DependencyObject; if (source == null) return;
DataRecordPresenter drp = Infragistics.Windows.Utilities.GetAncestorFromType(source,typeof(DataRecordPresenter), true, this.LookupDataGrid) as DataRecordPresenter; if (drp != null) { //--drp is not NULL when clicked any where in xmlDataGrid if(drp.IsActive) { // - when clicked on the active record but not on other records } } }
When you click on the DataRecordPresenter, couple of events will fire - RecordActiveting/ed and SelectedItemChanging/ed. If you want to be able to select the Record right away with click, you can set the CellClickAction to SelectRecord.
Please give us more information on what you are trying to achieve and why this PreviewMouseLeftButtonDown event is not working for you?
Thanks
I have CellClickAction set to SelectRecord and it is non-editable xamDatagrid. The only thing I need to do is record selection. Record can be selected by 2 ways: clicking the record and entering a value in the textbox that existing in any of the datagrid cells. textbox is placed above the datagrid. So on text change, I check for each cell in datagrid to find if the value and first matching value, I select that record and do few other functionality. To do this, I m listening to RecordActivated event.But there is some additional functionality I need to do when user has selected a record by clicking on it (and not by entering a value in the textbox) after the record is selected in the xamdatagrid.
If you click on a record, both RecordActivating and RecordActivated events will fire, together with the SelectionChanged pair of events. Maybe you should use a boolean variable to distinguish between the two types of selections.
Just to piggy-back off this..
If the record is already selected, none of the Activating, Activated, SelectedItemChanging or SelectedItemsChanged events fire (at least with 9.1 - can't say for 9.2).
Is this correct?
This is correct, they should not fire if you are clicking on already an active record.
So, if I wanted to cause some form of refresh based on a record in a grid (clicking / selecting causing the refresh) how could I do this if the record being clicked is already selected?
Paul
Paul,
If you need some logic that would fire each time you click on a record, no matter of the order of clicking, you probably want to handle for example PreviewMouseLeftButtonDown event of the DataRecordPresenter.
You can do that with the EventManager.RegisterClassHandler(...) method or with a style and EventSetter.