ScheduleView contextmenu display problem

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

    Posted 27 Feb 2014 Link to this post

    Hi,

    I'm working with the ScheduleView control and I use the Office2013 Theme. I set a context menu on my ScheduleView control with 2 options. I create an appointment on my control and when I right-click on the new appointment, the context menu appear, when I left-click in the new appointment cell but outside the context menu to make the context menu dissapear, the moving tooltip of the SchedulView control appear... I would like to know if it's possible to avoid this behavior?!?

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

    Posted 04 Mar 2014 Link to this post

    Hello Alain,

    In order to avoid the explained behavior you can use a custom ScheduleViewDragDropBehavior which will prevent the dragging when the ContextMenu was just closed. In your ViewModel you will need an additional property which indicates whether should prevent the drag operation and when the ContextMenu is closed you will need to set the property to true:

    public bool ShouldDisableDragOperation { get; set; }
     
    public bool IsContextMenuOpen
    {
        get
        {
            return this.isContextMenuOpen;
        }
        set
        {
            if (!(bool)value)
            {
                this.ShouldDisableDragOperation = true;
            }
            this.isContextMenuOpen = value;
            ...
        }
    }

    Afterward in the DragDropBehavior you can check the property in the CanStartDrag method the following way:

    public override bool CanStartDrag(DragDropState state)
    {
        var viewModel = (state.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView).DataContext as ViewModel;
     
        if (viewModel.ShouldDisableDragOperation)
        {
            viewModel.ShouldDisableDragOperation = false;
     
            return false;
        }
     
        return base.CanStartDrag(state);
    }

    However if you click somewhere else (not on the same Appointment) and ContextMenu is closed - the property will remain true and it will disable the dragging of the Appointments. So you may also need to bind the SelectedAppointment property of the ScheduleView and to set the ShouldDisableDragOperation property to false when the SelectedAppointment is changed.

    Hope this will help you.

    Regards,
    Kalin
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

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

    Posted 14 Mar 2014 in reply to Kalin Link to this post

    Hi Kalin,

    souns good except for one thing, the contextmenu is in the form where my usercontrol is so how my usercontrol can detect that the contexmenu is open or not???

    Thank's
    Alain
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 18 Mar 2014 Link to this post

    Hello Alain,

    If I understand you correctly you have an UserControl with ScheduleView inside and you have attached the ContextMenu to UserControl. In this case you can get the ContextMenu from the code behind of the UserControl using the static RadContextMenu.GetContextMenu() method and bind the its IsOpen property to a property in the ViewModel. Please check the following code snippet:

    public partial class ScheduleViewUserControl : UserControl
    {
        public ScheduleViewUserControl()
        {
            InitializeComponent();
            this.DataContext = new ViewModel();
        }
     
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var menu = RadContextMenu.GetContextMenu(this);
            var binding = new Binding{ Source = this.DataContext, Path = new PropertyPath("IsContextMenuOpen"), Mode = BindingMode.TwoWay};
            BindingOperations.SetBinding(menu, RadContextMenu.IsOpenProperty, binding);           
        }
    }

    Hope this will help you.

    Regards,
    Kalin
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  6. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 18 Mar 2014 in reply to Kalin Link to this post

    Hi Kalin,

    not exactly :) I have a wpf form which contain my usercontrol and the contextmenu was define in my wpf form. With the piece of code you gave me, the line "var menu = RadContextMenu.GetContextMenu(this);" return always null.

    Here is the definition of my usercontrol in my wpf form:

    <TabControl>
                <TabItem Header="Create Control">                
                    <ctrlCreateSchedule:CreateSchedule x:Name="CreateSchedule" GroupHeaderDateStringFormat="{}{0:dddd}" MinorTickLength="30" IsWeekendVisible="False" DayStartTime="9:00" DayEndTime="21:00" OnCreated="CreateSchedule_OnCreated" OnEdited="CreateSchedule_OnEdited" OnDeleted="CreateSchedule_OnDeleted" OnSelectionChanged="CreateSchedule_OnSelectionChanged" OnGetProperties="CreateSchedule_OnGetProperties" OnMouseRightButtonHeaderClick="CreateSchedule_OnMouseRightButtonHeaderClick" OnMouseRightButtonSpotsClick="CreateSchedule_OnMouseRightButtonSpotsClick" OnMouseRightButtonSlotsClick="CreateSchedule_OnMouseRightButtonSlotsClick" ContextMenuOpening="CreateSchedule_ContextMenuOpening" ContextMenuClosing="CreateSchedule_ContextMenuClosing">
                        <ctrlCreateSchedule:CreateSchedule.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Item A" />
                                <MenuItem Header="Item B" />
                                <MenuItem Header="Item C" />
                            </ContextMenu>
                        </ctrlCreateSchedule:CreateSchedule.ContextMenu>
                    </ctrlCreateSchedule:CreateSchedule>
                </TabItem>

    Thank's
    Alain
  7. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 19 Mar 2014 Link to this post

    Hello Alain,

    The approach I have suggested you uses RadContextMenu instead of the regular ContextMenu - that is why you get null for the Menu. Please try to replace the same approach using our ContextMenu:

    <TabControl>
        <TabItem Header="Create Control">
            <ctrlCreateSchedule:CreateSchedule ...>
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu>
                        <telerik:RadMenuItem Header="Item A" />
                        <telerik:RadMenuItem Header="Item B" />
                        <telerik:RadMenuItem Header="Item C" />
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>
            </ctrlCreateSchedule:CreateSchedule>
        </TabItem>
    </TabControl>

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  8. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 19 Mar 2014 in reply to Kalin Link to this post

    Thank's Kalin :)
  9. Aviv
    Aviv avatar
    4 posts
    Member since:
    Oct 2013

    Posted 23 Apr 2014 Link to this post

    Hi,
    I'm having a similar problem when using RadGanttView (right click shows the context menu, left click on the same task is causing a TaskSaving event - because of the Drag&Drop operation).

    Is there a way to change this behaviour (I do use the GanttDragDropBehaviour, with SchedulingDragDropState as the state)

    Thanks
    Aviv
  10. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 25 Apr 2014 Link to this post

    Hi Aviv,

    I noticed you have opened a ticket with the same question. We have already answered you there, so I'll ask to continue the conversation there as this thread is RadScheduleView related.

    However I'll share here the ScheduleView part of the answer so it would be available for the community:

    We were able to reproduce the ScheduleView issue and logged it in our Feedback portal, you can track its status on the following link:
    http://feedback.telerik.com/Project/143/Feedback/Details/126856-scheduleview-drag-and-drop-is-performed-when-left-clicking-after-right-clicking

    Hope this helps.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready