ScheduleView file-based saving/loading

2 Answers 19 Views
ScheduleView
Rob
Top achievements
Rank 2
Iron
Iron
Iron
Rob asked on 22 Aug 2025, 08:35 AM

I'm looking to load/save the appointments to a local file rather than a database.

I found a forum post from 2015 which seems a bit out of date.

Is there any facility for this and if not what is the suggested route? I don't want to ship a database source within my application.

Many thanks

2 Answers, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 25 Aug 2025, 08:35 AM

Hello Rob,

May I ask if it would be possible to take a look at the Ical demo from our Demos application, which demonstrates how to import and export appointments to the iCalendar type (file with .ics extension), which is used in calendars such as Google and Outlook

Additionally, you could also take a look at the following article from our documentation, which covers the import/export to ICalendar format:

WPF ScheduleView - Import/Export to ICalendar - Telerik UI for WPF

With this being said, I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Rob
Top achievements
Rank 2
Iron
Iron
Iron
answered on 25 Aug 2025, 08:55 AM

This works fine but....

My appointments are set up via a viewmodel:

 

<business:ScheduleViewModel x:Key="ViewModel" />

                                    <telerik:RadScheduleView
                                        x:Name="ScheduleCalendar"
                                        Grid.Row="1"
                                        AppointmentsSource="{Binding Appointments}"
                                        DataContext="{StaticResource ViewModel}">

 

How do I set the viewmodel content equal to the appointments loaded through the example load method (ics)?

 

Many many thanks!

Stenly
Telerik team
commented on 25 Aug 2025, 09:52 AM

Hello Rob,

I created a sample project that uses some of the logic of the ICal example, which is present in the same view model where the collection that contains the appointments is present.

With this being said, could you give the attached project a try?

Rob
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Aug 2025, 12:54 PM

Perfect thank you Stenly! 👍
Rob
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Aug 2025, 01:32 PM

One thing that doesn't seem to persist. When I load the appointments back in, the colours do not show up in the appointments - so the backgrounds are all the accent colour and not the individual task colour?
Stenly
Telerik team
commented on 27 Aug 2025, 01:28 PM

Hello Rob,

I tested this using the approach from the AppointmentColorBasedOnResource SDK example to color the appointments in combination with the import/export logic to/from ICalendar format, however, I was unable to reproduce this behavior.

I attached the test application, so, could you give it a try and let me know if I am missing something of importance?

Rob
Top achievements
Rank 2
Iron
Iron
Iron
commented on 28 Aug 2025, 05:56 PM

I have zipped up the solution and created a support ticket with my code to see if we can get to the bottom of this.
Stenly
Telerik team
commented on 02 Sep 2025, 10:59 AM

Hello Rob,

I provided an answer to this question in the support ticket, however, I will share the reason and solution to this here as well.

The observed behavior is expected, as the export logic of the control does not save the color of the categories. It only saves the category and display names. The import logic thus does not correctly apply the category brush when importing. Generally, this is also not supported by the ICalendar format, as it is intended to be interoperable across systems. However, this requirement can be achieved with a bit of custom code for checking the category name and applying a color based on it. 

To do so, extend the AppointmentCalendarImporter and override the ApplyAdditionalData method. In it, you could set the CategoryBrush property of the Category object of the generated Appointment instance on import. To get the correct color of each category, you could pass the RadScheduleView control.

The following code snippets showcase this suggestion's implementation:

public class CustomAppointmentCalendarImporter : AppointmentCalendarImporter
{
    private RadScheduleView scheduleView;

    public CustomAppointmentCalendarImporter(RadScheduleView scheduleView)
        : base(false)
    {
        this.scheduleView = scheduleView;
    }
    public CustomAppointmentCalendarImporter(bool ignoreParseErrors)
        : base(ignoreParseErrors)
    {
    }

    protected override IAppointment ApplyAdditionalData(IAppointment appointment, CalObject calObject)
    {
        Appointment appointmentWithAdditionalData = (Appointment)base.ApplyAdditionalData(appointment, calObject);

        if (appointmentWithAdditionalData.Category != null)
        {
            ((Category)appointmentWithAdditionalData.Category).CategoryBrush = this.scheduleView.CategoriesSource
                .OfType<Category>()
                .FirstOrDefault(c => c.CategoryName.Contains(appointmentWithAdditionalData.Category.CategoryName))?
                .CategoryBrush;
        }

        return appointmentWithAdditionalData;
    }
}
//On import action

var importer = new CustomAppointmentCalendarImporter(this.MyScheduleView);

With this being said, I hope the provided information will be of help to you.

Rob
Top achievements
Rank 2
Iron
Iron
Iron
commented on 02 Sep 2025, 11:06 AM

Perfect response and all worked excellently.
Stenly
Telerik team
commented on 02 Sep 2025, 11:53 AM

Hello Rob,

I am happy to hear that the proposed suggestion was of help to you and that you took the time to let us know.

Tags
ScheduleView
Asked by
Rob
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Rob
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or