Articles in this section
Category / Section

How to distinguish Multi-ICS file with Colors in WinRT Schedule?

3 mins read

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

 





Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied