Right Click location

3 posts, 0 answers
  1. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 10 Feb 2014 Link to this post

    Hi,

    I'm using the WeekViewDefinition and I would like to determine when the user click using his mouse right button if he clicked on an appointment, an empty slot or in the header of a columns where the control display the date, is so, I need to know on whivh volumn he clicked.

    Thank's
    Alain
  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 13 Feb 2014 Link to this post

    Hi Alain,

    We can get clicked item by subscribing to the MouseRightButtonUpEvent of the ScheduleView. Then in the handler you need to check whether the clicked element has parent of type AppointmentItem or GroupHeader if not you could check the ScheduleView MouseOverSlot property for the slot. Please try the following code snippet below (the ScheduleView is with x:Name="ScheduleView"):
    public MainWindow()
    {
        InitializeComponent();
        this.ScheduleView.AddHandler(UIElement.MouseRightButtonUpEvent, new MouseButtonEventHandler(MouseRightButtonUpEventHandler), true);
    }
     
    private void MouseRightButtonUpEventHandler(object sender, MouseButtonEventArgs e)
    {
        if ((e.OriginalSource as UIElement).ParentOfType<AppointmentItem>() != null)
        {
            var app = (e.OriginalSource as UIElement).ParentOfType<AppointmentItem>();
            Debug.WriteLine("Appointment clicked " + app.Appointment.Subject);
        }
        else if ((e.OriginalSource as UIElement).ParentOfType<GroupHeader>() != null)
        {
            var groupHeader = (e.OriginalSource as UIElement).ParentOfType<GroupHeader>();
            Debug.WriteLine("GroupHeader clicked " + groupHeader.Content);
        }
        else
        {
            // Should be Slot.
            if (this.ScheduleView.MouseOverSlot != null)
            {
                var slot = this.ScheduleView.MouseOverSlot;
                Debug.WriteLine("Slot clicked " + slot.Start);
            }
        }
    }

    Hope this works for you.

    Regards,
    Kalin
    Telerik

    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

  3. UI for WPF is Visual Studio 2017 Ready
  4. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 13 Feb 2014 in reply to Kalin Link to this post

    Work great :)

    Thank's
Back to Top