This is a migrated thread and some comments may be shown as answers.

Overwritting the DragAndDropBehavior Resize method

2 Answers 104 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Rebecca
Top achievements
Rank 1
Rebecca asked on 02 May 2011, 05:08 PM
I am implementing a DragAndDropBehavior class and have overwritten the Resize function; however I cannot figure out how to Resize the appointment without passing the state to the MyBase.Resize() method.

I have tried the following to resize the appointment, and the start&end properties of the underlying objects (the appointment) change but visual GUI representation for the appointment does not.

How do I resize the appointment's GUI representation?

Public Overrides Sub Resize(ByVal state As Telerik.Windows.Controls.DragDropState)

        Dim draggedAppointment As myCustomAppointment = Nothing
        If state.Appointment.GetType Is GetType(Occurrence) Then
            draggedAppointment = DirectCast(state.Appointment, Occurrence).Appointment
        ElseIf state.Appointment.GetType Is GetType(Appointment) Then
            draggedAppointment = DirectCast(state.Appointment, myCustomAppointment)
        End If

        If draggedAppointment IsNot Nothing Then
            Dim startTS As New TimeSpan(state.DestinationSlots(0).Start.DayOfWeek, state.DestinationSlots(0).Start.Hour, state.DestinationSlots(0).Start.Minute, state.DestinationSlots(0).Start.Second)
            Dim endTS As New TimeSpan(state.DestinationSlots(0).[End].DayOfWeek, state.DestinationSlots(0).[End].Hour, state.DestinationSlots(0).[End].Minute, state.DestinationSlots(0).[End].Second)

            If startTS <> draggedAppointment.TimePeriod.StartTime Then
                draggedAppointment.Start = state.DestinationSlots(0).Start
                state.DestinationSlots(0).Start = draggedAppointment.Start
            End If

            If endTS <> draggedAppointment.TimePeriod.EndTime Then
                draggedAppointment.End = state.DestinationSlots(0).End
                state.DestinationSlots(0).End = draggedAppointment.End
            End If
        End If

       'MyBase.Resize(state)
End Sub


Thank you for your time.

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 05 May 2011, 01:23 PM
Hello Rebecca,

I suggest you use BeginEdit() and Commit() methods in order to resize the appointment like this:

state.ServiceProvider.GetService(Of IObjectEditor(Of IAppointment)).BeginEdit(draggedAppointment)
 
'update the properties of the appointment here
draggedAppointment.Start = state.DestinationSlots(0).Start
draggedAppointment.End = state.DestinationSlots(0).End
 
state.ServiceProvider.GetService(Of IObjectEditor(Of IAppointment)).Commit()

Hope this helps.

All the best,
Yana
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
0
Rebecca
Top achievements
Rank 1
answered on 06 May 2011, 02:41 PM
Thank you for your help.
It works well now!
Tags
ScheduleView
Asked by
Rebecca
Top achievements
Rank 1
Answers by
Yana
Telerik team
Rebecca
Top achievements
Rank 1
Share this question
or