Set category on codebehind

2 posts, 0 answers
  1. John
    John avatar
    6 posts
    Member since:
    Nov 2013

    Posted 13 Jan 2014 Link to this post

    Hello. Help me. I want to change appointment's category in codebehind. Can i set it only by name of category? Default brushes are gradient?

    this code not change color
    new Appointment(){Subject="April",Start =DateTime.Today,End =DateTime.Today.AddHours(4), Category = new Category(){CategoryName = "Red Category"}}
     
  2. Kalin
    Admin
    Kalin avatar
    1246 posts

    Posted 14 Jan 2014 Link to this post

    Hi John,

    In order to add a Category to an Appointment you should not create a new Category but add an already existing one. You can find the Categories collection in the CategoriesSource property of the ScheduleView:

    var appointment = new Appointment();
    appointment.Category = this.scheduleView.CategoriesSource.Cast<Category>().FirstOrDefault(c => c.CategoryName == "Green Category");

    Hope this helps. If you have any other questions let us know.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top