Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Scheduler > Drag and Drop error with example

Not answered Drag and Drop error with example

Feed from this thread
  • Posted on Nov 8, 2011 (permalink)

    We are using the scheduler for a while now and the request has come to be able to drag and drop the appointments to a new slot.
    We are using some custom appointment objects and when i try to drag a whole Appointment nothing happens, and if I try to lengthen an appoint I get the following error.

    "   bij Telerik.Windows.DragDrop.DragInitializer.StartDrag() in c:\\TB\\101\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Controls\\DragDropManager\\DragInitializer.cs:regel 169\r\n   bij Telerik.Windows.DragDrop.DragInitializer.DragSourcePreviewMouseMove(Object sender, MouseEventArgs e) in c:\\TB\\101\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Core\\Controls\\DragDropManager\\DragInitializer.cs:regel 153\r\n   bij System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n   bij System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n   bij System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n   bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n   bij System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n   bij System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n   bij System.Windows.Input.InputManager.ProcessStagingArea()\r\n   bij System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n   bij System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n   bij System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)\r\n   bij System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   bij System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   bij MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   bij MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n   bij System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n   bij System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   bij System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   bij System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)\r\n   bij System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)\r\n   bij MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n   bij MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)\r\n   bij System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n   bij System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n   bij System.Windows.Threading.Dispatcher.Run()\r\n   bij System.Windows.Application.RunDispatcher(Object ignore)\r\n   bij System.Windows.Application.RunInternal(Window window)\r\n   bij System.Windows.Application.Run(Window window)\r\n   bij System.Windows.Application.Run()\r\n   bij RadTestProject.App.Main() in D:\\Projects\\RadTestProject\\RadTestProject\\obj\\Debug\\App.g.cs:regel 0\r\n   bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   bij System.Threading.ThreadHelper.ThreadStart()"


    I have made an example solution buy can not attach zips here is the code.

    Custom appointment
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using Telerik.Windows.Controls.Scheduler;
     
    namespace RadTestProject
    {
        public class AppointmentVM : AppointmentData, IEditableObject, IAppointment, IDataErrorInfo
        {
            #region Variables
            private AppointmentVM _copy;
            private bool _isInEditMode = false;
            private string _Color;
            #endregion
     
            #region Properties
            public string ShortSubject
            {
                get { return (!string.IsNullOrEmpty(ShortDescription) ? ShortDescription : Subject); }
            }
            public string Color
            {
                get
                {
                    return _Color;
                     
                }
                set
                {
                    _Color = value;
                    this.RaisePropertyChanged("Color");
                }
            }
            public bool IsInEditMode
            {
                get { return _isInEditMode; }
                private set
                {
                    if (_isInEditMode != value)
                    {
                        _isInEditMode = value;
                        this.RaisePropertyChanged("IsInEditMode");
                    }
                }
            }
            #endregion
     
            #region .Ctor
            public AppointmentVM() : base()
            {
                this.ID = 0;
                this.IsAllDayEvent = false;
                this.Start = DateTime.Now;
                this.End = DateTime.Now.AddDays(1);
                this.IsEmpty = false;
            }
     
            public AppointmentVM(AppointmentData anAppointment) : this()
            {
                CopyFrom(anAppointment);
            }
            #endregion
     
            public void CopyFrom(object toCopy)
            {
                if (toCopy is AppointmentData)
                {
                    this.ID = ((AppointmentData)toCopy).ID;
                    this.RoomID = ((AppointmentData)toCopy).RoomID;
                    this.UserID = ((AppointmentData)toCopy).UserID;
                    this.Subject = ((AppointmentData)toCopy).Subject;
                    this.StartDate = ((AppointmentData)toCopy).StartDate;
                    this.EndDate = ((AppointmentData)toCopy).EndDate;
                    this.IsAllDayEvent = (bool)((AppointmentData)toCopy).IsAllDayEvent;
                    this.IsDeleted = ((AppointmentData)toCopy).IsDeleted;
                    this.Body = ((AppointmentData)toCopy).Body;
                    this.Address = ((AppointmentData)toCopy).Address;
                    this.ShortDescription = ((AppointmentData)toCopy).ShortDescription;
                    this.Location = ((AppointmentData)toCopy).Location;
                    this.ProjectID = ((AppointmentData)toCopy).ProjectID;
                    this.Remark = ((AppointmentData)toCopy).Remark;
                }
            }
     
            #region IEditableObject Implementation
            public void BeginEdit()
            {
                if (!IsInEditMode)
                {
                    _copy = this.DeepClone() as AppointmentVM;
                    IsInEditMode = true;
                }
            }
     
            public void CancelEdit()
            {
                if (_copy != null)
                {
                    this.DeepClone(_copy, this);
                }
     
                _copy = null;
                IsInEditMode = false;
            }
     
            public void EndEdit()
            {
                _copy = null;
                IsInEditMode = false;
            }
            #endregion
     
            #region IDeepClonable Implementation
            public void DeepClone(object toClone, object aTarget)
            {
                if (toClone is AppointmentVM && aTarget is AppointmentVM)
                {
                    ((AppointmentVM)aTarget).ID = ((AppointmentVM)toClone).ID;
                    ((AppointmentVM)aTarget).Address = ((AppointmentVM)toClone).Address;
                    ((AppointmentVM)aTarget).RoomID = ((AppointmentVM)toClone).RoomID;
                    ((AppointmentVM)aTarget).UserID = ((AppointmentVM)toClone).UserID;
                    ((AppointmentVM)aTarget).Subject = ((AppointmentVM)toClone).Subject;
                    ((AppointmentVM)aTarget).ShortDescription = ((AppointmentData)toClone).ShortDescription;
                    ((AppointmentVM)aTarget).Start = ((AppointmentVM)toClone).Start;
                    ((AppointmentVM)aTarget).End = ((AppointmentVM)toClone).End;
                    ((AppointmentVM)aTarget).IsAllDayEvent = ((AppointmentVM)toClone).IsAllDayEvent;
                    ((AppointmentVM)aTarget).IsDeleted = ((AppointmentVM)toClone).IsDeleted;
                    ((AppointmentVM)aTarget).Body = ((AppointmentVM)toClone).Body;
                    ((AppointmentVM)aTarget).Location = ((AppointmentVM)toClone).Location;
                    ((AppointmentVM)aTarget).ProjectID = ((AppointmentData)toClone).ProjectID;
                    ((AppointmentVM)aTarget).Remark = ((AppointmentData)toClone).Remark;
                }
            }
     
            public object DeepClone(object toClone)
            {
                if (toClone is AppointmentVM)
                {
                    AppointmentVM appointment = new AppointmentVM();
                    this.DeepClone(toClone, appointment);
                    return appointment;
                }
     
                return null;
            }
     
            public object DeepClone()
            {
                return this.DeepClone(this);
            }
            #endregion
     
            public override bool Equals(object obj)
            {
                if (this.ID == 0)
                {
                    return base.Equals(obj);
                }
                else
                {
                    if (obj == null)
                    {
                        return false;
                    }
                    AppointmentVM compareObj = obj as AppointmentVM;
                    if ((object)compareObj == null)
                    {
                        return false;
                    }
     
                    return this.Equals(compareObj);
                }
            }
     
            public bool Equals(AppointmentVM compareObj)
            {
                if (this.ID == 0)
                {
                    return base.Equals(compareObj);
                }
                if ((object)compareObj == null)
                {
                    return false;
                }
     
                return (this.ID == compareObj.ID);
            }
     
            public override int GetHashCode()
            {
                return base.GetHashCode();
            }
     
            #region IAppointment Members
     
            public IAppointment Copy()
            {
                return this.DeepClone() as AppointmentVM;
            }
     
            public void CopyFrom(IAppointment other)
            {
                this.DeepClone(other, this);
            }
     
            public DateTime End
            {
                get
                {
                    return this.EndDate;
                }
                set
                {
                    this.EndDate = value;
                    this.RaisePropertyChanged("End");
                }
            }
     
            public RecurrenceRule RecurrenceRule
            {
                get
                {
                    return null;
                }
                set
                {
                    if (this.RecurrenceRuleChanged != null)
                    {
                        this.RecurrenceRuleChanged(this, new EventArgs());
                    }
                }
            }
     
            public event EventHandler RecurrenceRuleChanged;
     
            public DateTime Start
            {
                get
                {
                    return this.StartDate;
                }
                set
                {
                    this.StartDate = value;
                    this.RaisePropertyChanged("Start");
                }
            }
     
            new public string Subject
            {
                get
                {
                    return base.Subject;
                }
                set
                {
                    base.Subject = value;
                }
            }
     
            public TimeZoneInfo TimeZone
            {
                get;
                set;
            }
     
            public ResourceCollection Resources
            {
                get;
                internal set;
            }
     
            #endregion
     
            #region IEmpty Members
     
            public static AppointmentVM GetEmpty()
            {
                AppointmentVM toReturn = new AppointmentVM();
                toReturn.IsEmpty = true;
                return toReturn;
            }
     
            public bool IsEmpty
            {
                get;
                internal set;
            }
            #endregion
     
            #region IDataErrorInfo Members
     
            public string Error
            {
                get { return this["Start"] + this["Subject"]; }
            }
     
            public string this[string columnName]
            {
                get
                {
                    string results = null;
                    switch (columnName)
                    {
                        case "Start":
                            if (Start == null)
                            {
                                results = "Strings.StartDate_Required";
                            }
                            break;
                        case "Subject":
                            if (string.IsNullOrEmpty(Subject))
                            {
                                results = "Strings.Subject_Required";
                            }
                            break;
                        default:
                            results = string.Empty;
                            break;
                    }
                    return results ?? string.Empty;
                }
            }
     
            #endregion
     
        }
     
     
     
     
     
     
     
     
     
     
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.Runtime.Serialization.DataContractAttribute(Name = "AppointmentData", Namespace = "http://schemas.datacontract.org/2004/07/WcfProPlan.Models")]
        [System.SerializableAttribute()]
        public partial class AppointmentData : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
        {
     
            [System.NonSerializedAttribute()]
            private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string AddressField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string ProjectIDField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string RemarkField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string ShortDescriptionField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private long IDField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.Nullable<long> UserIDField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.Nullable<long> RoomIDField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.DateTime StartDateField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.DateTime EndDateField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string SubjectField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private bool IsAllDayEventField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private bool IsDeletedField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string BodyField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private bool IsSavedInExchangeField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.DateTime LastUpdatedField;
     
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string LocationField;
     
            [global::System.ComponentModel.BrowsableAttribute(false)]
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData
            {
                get
                {
                    return this.extensionDataField;
                }
                set
                {
                    this.extensionDataField = value;
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string Address
            {
                get
                {
                    return this.AddressField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.AddressField, value) != true))
                    {
                        this.AddressField = value;
                        this.RaisePropertyChanged("Address");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string ProjectID
            {
                get
                {
                    return this.ProjectIDField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.ProjectIDField, value) != true))
                    {
                        this.ProjectIDField = value;
                        this.RaisePropertyChanged("ProjectID");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string Remark
            {
                get
                {
                    return this.RemarkField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.RemarkField, value) != true))
                    {
                        this.RemarkField = value;
                        this.RaisePropertyChanged("Remark");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string ShortDescription
            {
                get
                {
                    return this.ShortDescriptionField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.ShortDescriptionField, value) != true))
                    {
                        this.ShortDescriptionField = value;
                        this.RaisePropertyChanged("ShortDescription");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 5)]
            public long ID
            {
                get
                {
                    return this.IDField;
                }
                set
                {
                    if ((this.IDField.Equals(value) != true))
                    {
                        this.IDField = value;
                        this.RaisePropertyChanged("ID");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 6)]
            public System.Nullable<long> UserID
            {
                get
                {
                    return this.UserIDField;
                }
                set
                {
                    if ((this.UserIDField.Equals(value) != true))
                    {
                        this.UserIDField = value;
                        this.RaisePropertyChanged("UserID");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 7)]
            public System.Nullable<long> RoomID
            {
                get
                {
                    return this.RoomIDField;
                }
                set
                {
                    if ((this.RoomIDField.Equals(value) != true))
                    {
                        this.RoomIDField = value;
                        this.RaisePropertyChanged("RoomID");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 8)]
            public System.DateTime StartDate
            {
                get
                {
                    return this.StartDateField;
                }
                set
                {
                    if ((this.StartDateField.Equals(value) != true))
                    {
                        this.StartDateField = value;
                        this.RaisePropertyChanged("StartDate");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 9)]
            public System.DateTime EndDate
            {
                get
                {
                    return this.EndDateField;
                }
                set
                {
                    if ((this.EndDateField.Equals(value) != true))
                    {
                        this.EndDateField = value;
                        this.RaisePropertyChanged("EndDate");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 10)]
            public string Subject
            {
                get
                {
                    return this.SubjectField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.SubjectField, value) != true))
                    {
                        this.SubjectField = value;
                        this.RaisePropertyChanged("Subject");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 11)]
            public bool IsAllDayEvent
            {
                get
                {
                    return this.IsAllDayEventField;
                }
                set
                {
                    if ((this.IsAllDayEventField.Equals(value) != true))
                    {
                        this.IsAllDayEventField = value;
                        this.RaisePropertyChanged("IsAllDayEvent");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 12)]
            public bool IsDeleted
            {
                get
                {
                    return this.IsDeletedField;
                }
                set
                {
                    if ((this.IsDeletedField.Equals(value) != true))
                    {
                        this.IsDeletedField = value;
                        this.RaisePropertyChanged("IsDeleted");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 13)]
            public string Body
            {
                get
                {
                    return this.BodyField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.BodyField, value) != true))
                    {
                        this.BodyField = value;
                        this.RaisePropertyChanged("Body");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 14)]
            public bool IsSavedInExchange
            {
                get
                {
                    return this.IsSavedInExchangeField;
                }
                set
                {
                    if ((this.IsSavedInExchangeField.Equals(value) != true))
                    {
                        this.IsSavedInExchangeField = value;
                        this.RaisePropertyChanged("IsSavedInExchange");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 15)]
            public System.DateTime LastUpdated
            {
                get
                {
                    return this.LastUpdatedField;
                }
                set
                {
                    if ((this.LastUpdatedField.Equals(value) != true))
                    {
                        this.LastUpdatedField = value;
                        this.RaisePropertyChanged("LastUpdated");
                    }
                }
            }
     
            [System.Runtime.Serialization.DataMemberAttribute(Order = 16)]
            public string Location
            {
                get
                {
                    return this.LocationField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.LocationField, value) != true))
                    {
                        this.LocationField = value;
                        this.RaisePropertyChanged("Location");
                    }
                }
            }
     
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
     
            protected void RaisePropertyChanged(string propertyName)
            {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }

    Window xaml
    <Window
            xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="RadTestProject.Window1"
            Title="Window1" mc:Ignorable="d" Loaded="Window_Loaded">
        <Window.Resources>
     
        </Window.Resources>
            <Grid>
                     
                <telerik:RadScheduler x:Name="Scheduler" AppointmentCreating="Scheduler_AppointmentCreating" FirstDayOfWeek="Monday"
                                      AppointmentSaving="Scheduler_AppointmentSaving" AppointmentAdded="Scheduler_AppointmentAdded" AppointmentTemplate="{DynamicResource AppointmentTemplate}" AppointmentEditing="Scheduler_AppointmentEditing" IsInlineEditingEnabled="False" ShowsConfirmationWindowOnDelete="False" AppointmentDeleting="Scheduler_AppointmentDeleting">
                <telerik:RadScheduler.Resources>
                    <DataTemplate x:Key="AppointmentTemplate">
                        <Grid Focusable="False" Background="{Binding Occurrence.Appointment.Color}" ToolTipService.ShowDuration="24000" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" MinHeight="20" />
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <ToolTipService.ToolTip>
                                <Border CornerRadius="2" VerticalAlignment="Top">
                                    <Grid Margin="8" MaxWidth="450" >
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Border Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#FF417542" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2" Margin="0,0,0,3">
                                            <Border BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="1,1,1,1" Background="{Binding Occurrence.Appointment.Color}" Padding="4" >
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition Height="Auto"/>
                                                    </Grid.RowDefinitions>
                                                    <TextBlock TextWrapping="Wrap" Text="{Binding Path=Occurrence.Appointment.Subject}" TextAlignment="Left" FontWeight="Bold" Margin="0,0,0,2" />
                                                    <TextBlock TextWrapping="Wrap" Text="{Binding Path=Occurrence.Appointment.Location}" TextAlignment="Left" FontWeight="Bold" Grid.Row="1" />
                                                </Grid>
                                            </Border>
                                        </Border>
                                        <TextBlock Grid.ColumnSpan="2" TextWrapping="Wrap" FontStyle="Italic" Grid.Column="0" Grid.Row="1" Text="{Binding Path=Occurrence.Appointment}"  TextAlignment="Left"/>
                                        <Label Grid.Column="0" Grid.Row="2" Content="user" Padding="0"/>
                                        <TextBlock TextWrapping="Wrap" FontStyle="Italic" Grid.Column="1" Grid.Row="2" Text="{Binding Path=Occurrence.Appointment.User.DisplayName}"  TextAlignment="Left"/>
                                        <Label Grid.Column="0" Grid.Row="3" Content="room" Padding="0" />
                                        <TextBlock TextWrapping="Wrap" FontStyle="Italic" Grid.Column="1" Grid.Row="3" Text="{Binding Path=Occurrence.Appointment.Room.DisplayName}"  TextAlignment="Left"/>
                                        <Label Grid.Column="0" Grid.Row="4" Content="status" Padding="0" />
                                        <TextBlock TextWrapping="Wrap" FontStyle="Italic" Grid.Column="1" Grid.Row="4" Text="{Binding Path=Occurrence.Appointment.Status}"  TextAlignment="Left"/>
                                        <Label Grid.Column="0" Grid.Row="5" Content="project" Padding="0" />
                                        <TextBlock TextWrapping="Wrap" FontStyle="Italic" Grid.Column="1" Grid.Row="5" Text="{Binding Path=Occurrence.Appointment.ProjectID}"  TextAlignment="Left"/>
                                        <Label Grid.Column="0" Grid.Row="6" Content="remark" Padding="0" Margin="0,0,5,0" />
                                        <TextBlock TextWrapping="Wrap" FontStyle="Italic" Grid.Column="1" Grid.Row="6" Text="{Binding Path=Occurrence.Appointment.Remark}"  TextAlignment="Left"/>
                                    </Grid>
                                </Border>
                            </ToolTipService.ToolTip>
     
                            <TextBox x:Name="PART_SubjectTextBox" BorderThickness="0" IsHitTestVisible="False" Text="{Binding Occurrence.Appointment.Subject}" BorderBrush="{x:Null}" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Margin="0" Background="{x:Null}">
                                <TextBox.Template>
                                    <ControlTemplate TargetType="{x:Type TextBoxBase}">
                                        <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" SnapsToDevicePixels="True">
                                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        </Border>
                                    </ControlTemplate>
                                </TextBox.Template>
                            </TextBox>
                            <TextBlock Grid.Row="1" Text="{Binding Occurrence.Appointment.Location, Mode=Default}" TextWrapping="Wrap" Margin="5,0,0,0" />
                            <TextBlock Grid.Row="2" Text="{Binding Occurrence.Appointment.Body, Mode=Default}" TextWrapping="Wrap" Margin="5,8,0,0" />
                        </Grid>
                    </DataTemplate>
                </telerik:RadScheduler.Resources>
                <telerik:RadScheduler.DayViewDefinition>
                    <telerik:DayViewDefinition TimeSlotLength="00:30:00" DayStartTime="06:00:00"/>
                </telerik:RadScheduler.DayViewDefinition>
                <telerik:RadScheduler.WeekViewDefinition>
                    <telerik:WeekViewDefinition VisibleDays="5" TimeSlotLength="00:30:00" DayStartTime="07:00:00"/>
                </telerik:RadScheduler.WeekViewDefinition>
                <telerik:RadScheduler.EditAppointmentStyle>
                    <Style TargetType="{x:Type telerik:AppointmentDialogWindow}">
                        <Style.Resources>
                            <telerik:AppointmentToTitleConverter x:Key="AppointmentToTitleConverter" />
                        </Style.Resources>
                        <Setter Property="Title" Value="{Binding Occurrence.Appointment, Converter={StaticResource AppointmentToTitleConverter}, RelativeSource={x:Static RelativeSource.Self}}" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type telerik:AppointmentDialogWindow}">
                                    <Grid DataContext="{TemplateBinding EditedAppointment}" Background="{TemplateBinding Background}" Width="430" >
                                        <Grid.Resources>
                                            <Style TargetType="{x:Type Label}">
                                                <Setter Property="HorizontalAlignment" Value="Right" />
                                                <Setter Property="VerticalAlignment" Value="Top" />
                                                <Setter Property="Margin" Value="0, 10, 0, 2" />
                                            </Style>
                                        </Grid.Resources>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" MinWidth="100" />
                                            <ColumnDefinition Width="*" MinWidth="315"/>
                                        </Grid.ColumnDefinitions>
                                        <Label Target="{Binding ElementName=Subject}" Content="Subject" />
                                        <TextBox x:Name="Onderwerp" Grid.Column="1" TabIndex="0" Text="{Binding Subject}" MaxLength="255" Margin="10, 10, 20, 2" />
                                        <Label Grid.Row="1" Target="{Binding ElementName=StartDateTime}" Content="Start" />
                                        <telerik:DateTimePicker x:Name="StartDateTime" Grid.Row="1"  Grid.Column="1" Margin="10, 10, 0, 2" IsEnabled="False"  SelectedDateTime="{Binding Start, Mode=TwoWay}" telerik:StartEndDatePicker.EndPicker="{Binding ElementName=EndDateTime}" />
                                        <Label Grid.Row="2" Target="{Binding ElementName=EndDateTime}" Content="End" />
                                        <telerik:DateTimePicker x:Name="EndDateTime"   Grid.Row="2" Grid.Column="1" Margin="10, 10, 0, 2" IsEnabled="False" SelectedDateTime="{Binding End, Mode=TwoWay}" />
                                        <CheckBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" Margin="10, 10, 0, 2" x:Name="cbAvailableCheck" Content="CheckAvailabilityUsers"/>
     
                                        <Label Grid.Row="4" Target="{Binding ElementName=cbUser}" Content="Strings" />
                                        <ComboBox x:Name="cbUser" Grid.Column="1" Grid.Row="4" ItemsSource="{Binding Source={StaticResource cvUsersComboBox}}" DisplayMemberPath="DisplayName"
                                                      SelectedItem="{Binding User, Mode=TwoWay}" Margin="10, 10, 20, 2" />
     
                                        <Label Grid.Row="5" Target="{Binding ElementName=cbRoom}" Content="Room" />
                                        <ComboBox x:Name="cbRoom" Grid.Column="1" Grid.Row="5" DisplayMemberPath="Name" ItemsSource="{Binding ServiceController.Rooms, Source={StaticResource ServiceController}}" SelectedItem="{Binding Room, Mode=TwoWay}" Margin="10, 10, 20, 2" />
     
                                        <CheckBox Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" IsChecked="{Binding IsAllDayEvent}" Margin="10, 10, 0, 2" x:Name="allDayEventCheckbox"  IsEnabled="False" Content="Strings"/>
                                        <Label Grid.Row="7" Target="{Binding ElementName=Body}" Content="Content" />
                                        <TextBox x:Name="Body" Grid.Row="7" Grid.Column="1" Text="{Binding Body}" TextWrapping ="NoWrap" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" AcceptsReturn="true" AcceptsTab="True" Margin="10, 10, 20, 2" MinHeight="100" />
                                        <StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal" Margin="10, 10, 0, 10">
                                            <Button Command="{x:Static telerik:RadSchedulerCommands.SaveAppointment}" Content="SaveAndClose" />
                                            <!--<Button Command="telerik:RadSchedulerCommands.EditRecurrenceRule" Margin="10, 0, 0, 0" Content="Wijzig patroon" />
                                                <Button Command="telerik:RadSchedulerCommands.EditParentAppointment" Margin="10, 0, 0, 0" Content="Wijzig hoofdafspraak" />-->
                                        </StackPanel>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger SourceName="allDayEventCheckbox" Property="IsChecked" Value="true">
                                            <Setter TargetName="StartDateTime" Property="TimePickerVisibility" Value="Collapsed" />
                                            <Setter TargetName="EndDateTime" Property="TimePickerVisibility" Value="Collapsed" />
                                        </Trigger>
                                        <DataTrigger Binding="{Binding EditedAppointment.RecurrenceRule}" Value="{x:Null}">
                                            <Setter TargetName="StartDateTime" Property="IsEnabled" Value="True" />
                                            <Setter TargetName="EndDateTime" Property="IsEnabled" Value="True" />
                                            <Setter TargetName="allDayEventCheckbox" Property="IsEnabled" Value="True" />
                                        </DataTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </telerik:RadScheduler.EditAppointmentStyle>
     
            </telerik:RadScheduler>
                     
            </Grid>
    </Window>

    Window CS
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Controls.Scheduler;
     
    namespace RadTestProject
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }
     
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                AppointmentVM app = new AppointmentVM();
                DateTime now = DateTime.Now;
                app.Start = new DateTime(now.Year, now.Month, now.Day, 9,0,0);
                app.End = new DateTime(now.Year, now.Month, now.Day, 17,0,0);
                app.Subject = "test";
                Scheduler.Appointments.Add(app);
            }
     
            private void Scheduler_AppointmentCreating(object sender, AppointmentCreatingEventArgs e)
            {
                e.NewAppointment = new AppointmentVM();
            }
     
            private void Scheduler_AppointmentSaving(object sender, AppointmentSavingEventArgs e)
            {
                if ((e.Appointment as AppointmentVM) != null)
                {
                    //if (ServiceController.GetInstance().LogedInUser != null && ServiceController.GetInstance().LogedInUser.Rights == ProPlan.ServiceProPlan.UserRights.Management)
                    //{
                    //    ServiceController.GetInstance().UpdateAppointmentAsync(e.Appointment as AppointmentVM);
                    //    ReloadAppointments();
                    //}
                }
            }
     
            private void Scheduler_AppointmentAdded(object sender, AppointmentAddedEventArgs e)
            {
                Scheduler.Appointments.Clear();
            }
     
            private void Scheduler_AppointmentEditing(object sender, AppointmentEditingEventArgs e)
            {
                if (e.AppointmentEditAction == Telerik.Windows.Controls.Scheduler.AppointmentEditAction.Edit)
                {
                    AppointmentVM appointment = (e.Appointment as AppointmentVM);
                    //if (appointment.ProjectItemDate != null && appointment.ProjectItemDate.ProjectItemID != null && appointment.ProjectItemDate.ProjectItemID > 0)
                    //{
                    //    e.Cancel = true;
                    //    ServiceController.GetInstance().GetProjectByProjectItemDateIDAsync((long)appointment.ProjectItemDate.ProjectItemID);
                    //}
                }
            }
     
            private void Scheduler_AppointmentDeleting(object sender, AppointmentDeletingEventArgs e)
            {
                e.Cancel = true;
            }
        }
    }

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Nov 11, 2011 (permalink)

    Hi Kevin,

    I am not able to create a project from the code snippets, as they are too much custom dependencies. Could you please open a support ticket and send the project back to us. In that way we will be able to provide you with a solution in a timely manner.

    Looking forward to your reply.

    Best wishes,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Scheduler > Drag and Drop error with example
Related resources for "Drag and Drop error with example"

WPF Scheduler Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]