RadScheduler disable Drag'n'Drop

9 posts, 1 answers
  1. Steffen
    Steffen avatar
    77 posts
    Member since:
    Mar 2009

    Posted 08 Mar 2010 Link to this post

    Hi,

    it seems the RadScheduler's drag 'n' drop behaviour has changed.
    Inside my AppointmentTemplates for the Day-View I have a lot of "custom" drag 'n' drop functionality (and scrollviewers) which was no problem before.
    But with the beta the RadGridView's own Drag'n'Drop starts immediately and tries to move the appointment.

    How can I disable the drag'n'drop? Or maybe there is another solution.

    Best Regards
    Steffen
  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 09 Mar 2010 Link to this post

    Hi Steffen,

    Thank you for contacting us.

    Could you please send us sample running project or the code for the AppointmentTemplate to see what the problems are?

    As for disabling drag and drop functionality - there is 2 ways to do that:

    1.Set the IsReadOnly property of scheduler to true.
    2.Hook on the AppointmentEditing event and set e.Cancel = true in its event handler.

    Regards,
    Rosi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Steffen
    Steffen avatar
    77 posts
    Member since:
    Mar 2009

    Posted 09 Mar 2010 Link to this post

    Hi Rosi,

    thank you for suggesting these workarounds. Canceling the Edit-event behaves a little different from setting IsReadonly to true. While my custom Drag'n'Drop works in both cases, canceling the Edit-event makes the AppointmentTemplate's ScrollViewer's "undraggable" (clicking works).

    Here is a short repro (try to scroll the Hugo's):
      public partial class Window1 : Window 
        { 
            public Window1() 
            { 
                InitializeComponent(); 
     
                ObservableCollection<MyAppointment> col = new ObservableCollection<MyAppointment>(); 
     
                MyAppointment a = new MyAppointment(); 
                a.Start = DateTime.Now; 
                a.End = a.Start.AddHours(1); 
     
                for (int i = 0; i < 100; ++i) a.Persons.Add(new Person() { Name = "Hugo" }); 
                
                col.Add(a); 
     
                scheduler.AppointmentsSource = col; 
     
                scheduler.ViewMode = Telerik.Windows.Controls.SchedulerViewMode.Day; 
                scheduler.SelectedAppointment = a; 
            } 
     
            private void PersonListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
            { 
                //custom drag'n'drop code goes here.... 
     
                //the appointment shoudn't move 
            } 
        } 
     
        public class MyAppointment : AppointmentBase 
        { 
            public override IAppointment Copy() 
            { 
                throw new NotImplementedException(); 
            } 
     
            private ObservableCollection<Person> m_persons = new ObservableCollection<Person>(); 
            public ObservableCollection<Person> Persons 
            { 
                get { return m_persons; } 
                set { m_persons = value; } 
            } 
        } 
     
        public class Person 
        { 
            public string Name { getset; } 
        } 

    <Window x:Class="RadSchedulerDragDrop.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        Title="Window1" Height="600" Width="600"
        <Window.Resources> 
            <DataTemplate x:Key="AppointmentTemplate"
                <ListBox ItemsSource="{Binding Path=Occurrence.Appointment.Persons}" ScrollViewer.VerticalScrollBarVisibility="Visible" PreviewMouseLeftButtonDown="PersonListBox_PreviewMouseLeftButtonDown"
                    <ListBox.ItemsPanel> 
                        <ItemsPanelTemplate> 
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left"/> 
                        </ItemsPanelTemplate> 
                    </ListBox.ItemsPanel> 
                     
                    <ListBox.ItemTemplate> 
                        <DataTemplate> 
                            <TextBlock Width="100" Text="{Binding Path=Name}"/> 
                        </DataTemplate> 
                    </ListBox.ItemTemplate> 
                </ListBox> 
            </DataTemplate> 
             
        </Window.Resources> 
        <Grid> 
            <telerik:RadScheduler Name="scheduler" OpenModalDialogs="False" AppointmentTemplate="{StaticResource AppointmentTemplate}"
                 
            </telerik:RadScheduler> 
        </Grid> 
    </Window> 

     Best Regards
    Steffen

  5. Steffen
    Steffen avatar
    77 posts
    Member since:
    Mar 2009

    Posted 11 Mar 2010 Link to this post

    Hi,

    with the new release Q1_2010 setting scheduler.IsReadonly=true also sets the appointment-templates readonly(didn't happen with the beta)  - so I have to cancel the edit-event which makes the appointment's Srollviewer "undraggable" (if dragging enough it starts jumping).
    Maybe there is another solution to avoid the scheduler's drag'n'drop-functionality? Maybe by modifying my custom theme(HitTestVisibility or something like that).


    Best Regards
    Steffen
  6. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 11 Mar 2010 Link to this post

    Hi Steffen,

    I modified the code that you provided illustrating how you can achieve the goal insted of using the IsReadOnly property. Please add the code in yellow to your application.

    <DataTemplate x:Key="AppointmentTemplate">
                <ListBox  Loaded="ListBox_Loaded" ItemsSource="{Binding Path=Occurrence.Appointment.Resources}" ScrollViewer.VerticalScrollBarVisibility="Visible" >
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Width="100" Text="{Binding Path=ResourceName}"/>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DataTemplate>


    private void ListBox_Loaded(object sender, RoutedEventArgs e)
            {
                System.Windows.Controls.ListBox list = sender as System.Windows.Controls.ListBox;
                AppointmentItem item = list.ParentOfType<AppointmentItem>();
                RadDragAndDropManager.SetAllowDrag(item, false);
            }

    Hope this helps.

    Kind regards,
    Rosi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Steffen
    Steffen avatar
    77 posts
    Member since:
    Mar 2009

    Posted 11 Mar 2010 Link to this post

    Hi,

    thank you so much. This is exactly what I needed!

    There is just one little thing left: How can I get rid of the Hand-Cursor?
    It's still there and I need my own DragOver-Cursors to show up again, so people can see what they can(or can't) drag inside my appointment.

    Best Regards
    Steffen
  8. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 12 Mar 2010 Link to this post

    Hi Steffen,

    I suggest you just set the Cursor property of the ListBox to Arrow:

    <ListBox Cursor="Arrow" .../>


    Regards,
    Rosi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 13 Apr 2010 Link to this post

    Hi,

    I don't know why I'm getting disabled = "disabled" in my appointment template! Crazy, I don't know what I touched that I started looking like this.... Is there any reason why the appointmentTemplate can have disabled="disabled" ???? I don't know where it's coming from

    regards.

    jose
  10. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 15 Apr 2010 Link to this post

    Hello Jose Granja,

    Thank you for contacting us.

    Could you please send us your project or a sample app demonstrating that? Thus we can be more productive in finding the right solution for you.

    Thank you in advance.

    Sincerely yours,
    Teodor
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WPF is Visual Studio 2017 Ready