How to use custom appointment?

15 posts, 0 answers
  1. anatoly
    anatoly avatar
    13 posts
    Member since:
    Nov 2010

    Posted 17 Nov 2010 Link to this post

    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
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 17 Nov 2010 Link to this post

    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>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. anatoly
    anatoly avatar
    13 posts
    Member since:
    Nov 2010

    Posted 18 Nov 2010 Link to this post

    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.

  5. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    the same is happening with me
  6. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    I solve the problem implementing copyfrom, copy.
  7. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 23 Nov 2010 Link to this post

    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
  8. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    I now have another problem. I want to change the style of AppointmentItem, but that the bindings to the propridades CostumAppoitment not work.
  9. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    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);
            }
        }
    }
  10. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    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....
  11. Nuno Cruz
    Nuno Cruz avatar
    17 posts
    Member since:
    Mar 2010

    Posted 23 Nov 2010 Link to this post

    Datacontext have a Appointment proxy, i need a CostumAppointment proxy  
  12. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 25 Nov 2010 Link to this post

    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
  13. Cees
    Cees avatar
    4 posts
    Member since:
    Aug 2012

    Posted 30 Nov 2010 Link to this post

    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

  14. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 03 Dec 2010 Link to this post

    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
  15. Cees
    Cees avatar
    4 posts
    Member since:
    Aug 2012

    Posted 07 Dec 2010 Link to this post

    Miroslav,

    Thank for the clearifying example

    Cees
  16. Madan
    Madan avatar
    3 posts
    Member since:
    Apr 2012

    Posted 05 Jul 2012 Link to this post

    .
Back to Top
UI for WPF is Visual Studio 2017 Ready