We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to differentiate Schedule Appointments by background color, when more than one ICS files are imported in the same application?

Platform: WinRT |
Control: SfSchedule
Tags: sfschedule

The schedule appointments can be differentiated by its background when you import more than one ICS files in the same application.

 

Create a WinRT application and add SfSchedule by specifying the AppointmentCollectionChanged Event Handler in it.

 

XAML

            <syncfusion:SfSchedule Grid.Column="0"  x:Name="Schedule"  AppointmentSelectionBrush="Red"
                 ScheduleType="Week"
                 Background="White"
AppointmentCollectionChanged="Schedule_AppointmentCollectionChanged" />

 

By triggering the AppointmentCollectionChanged event of schedule, the imported ICS file in Schedule can be differentiated by changing the Schedule AppointmentBackground property before importing new ICS file.

 

C#

      private void Schedule_AppointmentCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            var schedule = sender as SfSchedule;
            var newapp = ((object[])e.NewItems.SyncRoot).First() as ScheduleAppointment;
            newapp.AppointmentBackground = MyBrsh;
        }

 

You can use the SfColorPicker control to set the schedule AppointmentBackgroundcolor and its SelectedColor property is binded with local property that is used to set the AppointmentsBackgroundcolor to differentiate the new ICS file that is imported.

 

XAML

                <media:SfColorPicker Margin="10 5" SelectedColor="{Binding MyBrsh, Converter={StaticResource brushConv},  Mode=TwoWay}" Height="120"/>

 

You can use the converter to select the color in SfColorPicker.

C#

public class BrushToColorConverter : IValueConverter
    {
        object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is SolidColorBrush)
                return (value as SolidColorBrush).Color;
            if (value is Color)
                return new SolidColorBrush((Color)value);
            return null;
        }
        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
        {
            if (value is SolidColorBrush)
                return (value as SolidColorBrush).Color;
            if (value is Color)
                return new SolidColorBrush((Color)value);
            return null;
        }
    }

 

Schedule ExportICS and ImportICS methods are handled in button click event to differentiate the ICS file in schedule.

C#

  private void Import_Click(object sender, RoutedEventArgs e)
        {
            Schedule.ImportICS();
        }
        private void Export_Click(object sender, RoutedEventArgs e)
        {
            Schedule.ExportICS();
        }

 

Sample Link: 

Schedule_ImportICS.zip

 

The following screenshots displays to differentiate ICS in Schedule by changing appointmentsbackgroundcolor.

 

ICS file import

Figure 1: Single ICS file import

 

 

ICS import file

Figure 2: Differentiating ICS file when more than one import

 

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile