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
225
RecordActivated event on mouseenter instead of onclick
posted

Is there any way to get the RecordActivated event to fire on a mouseover instead of when it is clicked?

 

I want a popup to appear when i mouse over the row instead of when i click on it with information about the row i am moused over.

 

Right now, i have code like this

 

<igDP:XamDataPresenter 

            x:Name="DataPresenter1"

            DataSource="{Binding Path=Data}"

            RecordActivated="DataPresenter1_RecordActivated">

 

where the event gets fired once i click on a row and everything works fine.  but I would like it to handle my popup on mouse enter instead.  any ideas?  is it also possible to get my mouse location and have the popup appear next to my mouse?

Parents
No Data
Reply
  • 69686
    Verified Answer
    posted

    Hello,

    This is possible, following these steps:

    1. Registed a MouseEnter event for the DataRecordPresenter, or DataRecordCellArea, using the EventManager class:

                EventManager.RegisterClassHandler(typeof(DataRecordPresenter), DataRecordPresenter.MouseEnterEvent, new MouseEventHandler(drp_MouseEnter));

    void drp_MouseEnter(object sender, MouseEventArgs e)

            { ... }

    2. Make the record active when you enter the DataRecordPresenter in the drp_MouseEnter handler:

                p.IsOpen = false;

                DataRecordPresenter drp = sender as DataRecordPresenter;

                drp.Record.IsActive = true;

    3. This will fire the RecordActivated event, which you can use to show your popup (p)

            private void xamDataGrid1_RecordActivated(object sender, Infragistics.Windows.DataPresenter.Events.RecordActivatedEventArgs e)
            {
                p.Placement = PlacementMode.Mouse;
                TextBlock t = new TextBlock() { Background = Brushes.White, Foreground = Brushes.Black };
                t.Text = e.Record.ToString();
                p.Child = t;
                p.IsOpen = true;
            }
    The Placement property , set to Mouse will show the popup next to the mouse cursor.
    In this code snippet, I am hiding the popup in mouse event and showing it is RecordActivated. You can however, register another - MouseLeave event and hide the popup there.
    Let me know if you have questions on this:

Children