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

How to use custom appointment?

14 Answers 294 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
anatoly
Top achievements
Rank 1
anatoly asked on 17 Nov 2010, 02:48 PM
Hi,

I've tried to use custom appointment calss similar to RadScheduler as described here but not successfull.

I see neither NewAppointment property in AppointmentCreatingEventArgs class nor BaseAppointmentCollection<IAppointment> in the RadScheduleView assembly.

What am I doing wrong?

Thanks,
Anatoly

14 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 17 Nov 2010, 03:37 PM
Hello Anatoly,

In RadScheduleView it is a bit different.

1) Instead of using BaseAppointmentCollection<IAppointment> you could use plain ObservableCollection<CustomAppointment>. It is important to use your CustomAppointment class as generic parameter for the ObservableCollection in order to enable RadScheduleView to properly instantiate appointments of your class.

2) You should use the AppointmentCreated event to set properties on the newly created appointment through the Appointment property of the event args.

Kind regards,
Valeri Hristov
the Telerik team
See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
anatoly
Top achievements
Rank 1
answered on 18 Nov 2010, 02:57 PM
Hello Valeri,

I've tried your solution and got an exception when adding new appointment. It happens between AppointmentCreating and AppointmentCreated events.

The value "New Subject : 18.11.2010 0:00:00 - 25.11.2010 0:00:00" is not of type "MyWpfApplication.MyAppointment" and cannot be used in this generic collection.
 
   at System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
   at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value)
   at Telerik.Windows.Controls.ScheduleView.ScheduleViewDataConnection.HackCollectionViewBug(Boolean isCommit) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q3\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\ScheduleViewDataConnection.cs:line 887

MyAppointment is my custom appointment class. By the way, e.Appointment is of correct type MyAppointment on AppointmentCreating.

Could you please advise?

Regards,
Anatoly.

0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 01:17 PM
the same is happening with me
0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 01:42 PM
I solve the problem implementing copyfrom, copy.
0
Miroslav Nedyalkov
Telerik team
answered on 23 Nov 2010, 04:04 PM
Hello Everybody,

 As Nuno correctly noticed, it is very important to implement the Copy method, because it creates a new instance and we need this in various scenarios. In this case this should be enough to fix the problem.

Best wishes,
Miroslav Nedyalkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 04:38 PM
I now have another problem. I want to change the style of AppointmentItem, but that the bindings to the propridades CostumAppoitment not work.
0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 05:25 PM
I know what it was. My properties must be defined as follows:

public
string ClientCode
{
    get
    {
        return base.Storage<ServiceAppointment>().clientCode;
    }
    set
    {
        ServiceAppointment storage = base.Storage<ServiceAppointment>();
        if (storage.clientCode!= value)
        {
            storage.clientCode= value;
            this.OnPropertyChanged<string>(() => this.ClientCode);
        }
    }
}
0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 06:22 PM
Sorry but the solution is not complete, the binding dont work
<Setter Property="ContentTemplate">
   <Setter.Value>
       <DataTemplate>
           <TextBlock Text="{Binding Path=ClienteCode}" />
       </DataTemplate>
   </Setter.Value>
</Setter>


The binding dont work with ClienteCode but work with End, subject  etc....
0
nuno
Top achievements
Rank 1
answered on 23 Nov 2010, 07:15 PM
Datacontext have a Appointment proxy, i need a CostumAppointment proxy  
0
Miroslav Nedyalkov
Telerik team
answered on 25 Nov 2010, 01:22 PM
Hi Nuno,

 You could use the Appointment property of the proxy which is the actual appointment. We are currently working on overcoming this limitation.

Kind regards,
Miroslav Nedyalkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Cees
Top achievements
Rank 1
answered on 30 Nov 2010, 06:00 PM
I have the same problem. Working with custum appointments is more complex then neccessary. I suugest that your solution will offer een factory that can be injected in the ScheduleView. Product of the factory.Create will be a IAppointment.

Success

0
Miroslav Nedyalkov
Telerik team
answered on 03 Dec 2010, 01:34 PM
Hi Cees,

 We don't need a factory as we use an EditableCollectionView which creates objects correctly. For more information about creating custom appointments you could refer the following blog post - http://blogs.telerik.com/blogs/posts/10-11-25/how_to_create_custom_appointments_and_custom_appointment_dialog_in_telerik_scheduleview.aspx.

Hope this helps!

Greetings,
Miroslav Nedyalkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Cees
Top achievements
Rank 1
answered on 07 Dec 2010, 06:18 PM
Miroslav,

Thank for the clearifying example

Cees
0
Madan
Top achievements
Rank 1
answered on 05 Jul 2012, 10:11 AM
.
Tags
ScheduleView
Asked by
anatoly
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
anatoly
Top achievements
Rank 1
nuno
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Cees
Top achievements
Rank 1
Madan
Top achievements
Rank 1
Share this question
or