Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag Drop (Read 5544 times)
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Drag Drop
Jun 10th, 2010 at 12:24pm
Print Post  
Hi,

Does the calendar support drag and drop events?

I have set AllowDrop to True, but nothing is fired in the Drop or DragOver events of a calendar.

I'm trying to drap/drop appointments between two diaries.

Thanks
Matt
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop
Reply #1 - Jun 10th, 2010 at 1:08pm
Print Post  
I subscribe to the events and they fire as expected. What code are you using?

Regards,
Meppy
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: Drag Drop
Reply #2 - Jun 10th, 2010 at 1:24pm
Print Post  
Hi,

My XAML is as follows;

Code
Select All
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <planner:Calendar Name="calendar1"
                          Grid.Column="0"
                          Theme="Windows2003"
                          CurrentView="Timetable"
                          AllowInplaceCreate="False"
                          AllowInplaceEdit="False"/>

        <planner:Calendar Name="calendar2"
                          Grid.Column="1"
                          Theme="Windows2003"
                          CurrentView="Timetable"
                          AllowDrop="True"
                          AllowInplaceCreate="False"
                          AllowInplaceEdit="False"
                          Drop="calendar_Drop"
                          DragOver="calendar_DragOver" />
    </Grid>
 



My code behind creates dates and a resource for each calender, and an appointment for calendar1.

When I drag the appointment from calendar1 to calendar2, neither the Drop or DragOver events fire.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop
Reply #3 - Jun 10th, 2010 at 1:37pm
Print Post  
Modifying an appointment interactively within the calendar is not considered a Windows drag&drop operation. It is a native operation for the Calendar control which is only effective within the control.

In order to initiate a true Windows (cross-control and cross-application) drag&drop, you need to invoke the System.Windows.DragDrop.DoDragDrop static method. I found that a very convenient place to initiate this operation is in the ItemClick event of the source Calendar control (calendar1 in your case).

My event handler looks similar to the following:

Code
Select All
private void calendar1_ItemClick(object sender, ItemMouseEventArgs e)
{
      calendar1.ResetDrag();
      DragDrop.DoDragDrop(calendar1, e.Item, DragDropEffects.Copy);
} 


Let me know if this works.

Regards,
Meppy
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: Drag Drop
Reply #4 - Jun 10th, 2010 at 3:29pm
Print Post  
Hi,

Yes you are right - this is now working fine.

How do you get the drop location? I have the code below, but it always returns a null datetime.

Code
Select All
            Point p = e.GetPosition(calendar);
            Point pt = this.PointToScreen(p);

            // get the start/end time of the drop location
            DateTime? startTime = calendar.GetDateAt(pt);
            if (!startTime.HasValue)
                return;
 



Thanks
Matt

  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop
Reply #5 - Jun 11th, 2010 at 5:44am
Print Post  
The point supplied as argument should be in calendar coordinates. Therefore, in your case, simply pass p.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: Drag Drop
Reply #6 - Jun 14th, 2010 at 2:43pm
Print Post  
Yes - this works.

Thanks for your help.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint