During a drag and drop, is there anyway I could find out over which specific day of a XamMonthCalendar control the user chose?
I am familiar with WPF drag and drop and I have hooked up the oXamMonthCalendar_DragOver, oXamMonthCalendar_Drop and oXamMonthCalendar_DragLeave events.
If there's any chance of this being done, I can create a test application I can upload with the basic drag and drop functionality.
The e.OriginalSource for the events should still be whatever descendant element was hit-tested so you could probably use something like our Utilities.GetAncestorFromType to get the calendar item you are over.
Hi Andrew,
Unfortunately, this is not working - I'm getting the CalendarDay using Utilities.GetAncestorFromType, but the CalendarDay.StartDate is always "8/25/2008".
I tried it and it seems to work fine. In what event are you looking at it? I tried using Drop and DragOver and in both cases it gave me the correct element. Can you post a sample demonstrating the problem?
I created a sample app which I had sent to support. I'll clean it up a bit and add the code that accesses the CalendayDay. I'll have something ready by tomorrow.
Andrew, thanks for the help!
Andrew, you'll find my sample project here:
[... sample project deleted ...]
Once you extract the contents you can run bin\Debug\XamMonthCalendarTest.exe; source code can be compiled using XamMonthCalendarTest.vbproj
Notice that in both oXamMonthCalendar_DragOver() and oXamMonthCalendar_Drop(), oCalendarDay is always "8/25/2008".
I'm not in a place to run your code but a quick look seems to indicate that you are using "sender" and not "e.OriginalSource" as I recommended in the call to GetAncestorFromType - the sender in an event handler will always be the class for which you have added the event (so the XMC in this case).
You're right, using e.OriginalSource and GetAncestorFromType worked! Here's the line I had to correct:
oCalendarDay = CType(GetAncestorFromType(e.OriginalSource, GetType(CalendarDay), False), CalendarDay)
Thanks!
Note: I have deleted my test project - but if anyone is interested in getting a copy, shoot me an email through www.ehuna.org.