简体   繁体   中英

Highlight Multiple Dates in WinRT XAML Toolkit - Calendar Control

I am writing a Windows Phone 8.1 (XAML) App . I used WinRT XAML Toolkit - Calendar Control in it. I want to show holidays highlighted on this calendar. Data of holidays comes from server (JSON):

for (int i = 0; i < ServerResponse.Holidays.Count; i++)
{
    string[] DateArray = ServerResponse.Holidays[i].ActivityDate.Split('-');    
    //Highlight Holidays in calendar
    ActivityCalender.SelectedDate = new DateTime(int.Parse(DateArray[2]), int.Parse(DateArray[1]), int.Parse(DateArray[0]));

}

XAML:

<WinRT:Calendar x:Name="ActivityCalender" 
    SelectedDatesChanged="ActivityCalender_SelectedDatesChanged">            

</WinRT:Calendar>

C#:

private void ActivityCalender_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
    {

    }

The problem is that if one item is added to SelectedDate, previous one gets removed. I checked SelectionChangedEventArgs e . There is 1 AddedItems and 1 RemovedItems . Why is previous date getting removed if I add another date?

private void ActivityCalender_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{

    for (int i = 0; i < GetActivityResponseObject.Workouts.Count; i++)
    {
        string[] DateArray = GetActivityResponseObject.Workouts[i].ActivityDate.Split('-');

        ActivityCalender.SelectedDates.Add(new DateTime(int.Parse(DateArray[2]), int.Parse(DateArray[1]), int.Parse(DateArray[0])));
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM