Hi,
We are using XAMCalendar. We added some styles for BackGround Color. But In Some case we want to refresh the Calendar or reload. Is there any way to reload or refresh the Calendar for showing default calendar view.We have already used UpdateLayout and UpdateDefaultStyle. But its not working.
Please let us aware.
Thanks.
For that I would suggest just defaulting the Min and Max dates to the start and end of the year. (use whatever years you want to start with)
MinDate = new DateTime(2016, 1, 1);MaxDate = new DateTime(2016, 12, 31);
This will let your calendar show all the months and then your users can change the min and max through the DatePickers on screen which will then adjust the calendar accordingly.
Thanks for your wonderful support. only one thing I wish to know that If Max date binds in View Model then first time while loading of calendar not showing all calendar Months. Initial or first time loading of calendar we want to show all calendar moths as default view of calendar after that If we select picker date then we can set Max date and Min Date from View Model.Only First time while loading of calendar want to show all months in calendar.
Right now if we bind Max and Min date in ViewModel then Initial loading of calendar not showing all months. Please let us aware how we can set default view or can display all months in calendar at first time.
Hi Kanwar,
Sorry, it wasn't clear that you needed the background and foreground to change only on specific calendar days. For that you will need to use a style which means you need to manually trigger the converter to fire by triggering a property changed notification. I'll assume that you have a MaxDate property in your view model and that your binding that has the converter is attached to the MaxDate property. To trigger a refresh just trigger the notification on MaxDate. I.e.:
void NotifyPropertyChanged(string propertyName){ if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));}
NotifyPropertyChanged("MaxDate");
Make sure your view model has implemented INotifyPropertyChanged.
Thanks for your support. But is there any way to change background and Foreground color of Calendar Day instead of whole calendar without using converter. We want to change background and Foreground only individual or some dates.
Thanks
Ok, so you have converters attached to the max date property and when the max date is changed your converter will change the background and foreground color. Is that correct?
Why not just bind the XamCalendar Background and Foreground directly to some color property in your view model? Then you can have some logic in your view model that will change the color based on the MinDate and MaxDate properties that you also have in your view model. I'm not sure why you need to use a converter for what you described.
Either way, your converter is not firing again because your DatePicker value did not change. If the value does not change then no property changed notification will fire and your converter won't trigger. Converters are triggered by property change notifications. So if you want to "refresh" the calendar then you need to trigger a property change notification on the property that your converter is attached to. I.e.:
If your binding looks like this:
"{Binding Path=MaxDate, Converter={StaticResource MyConverter}}"
You need to trigger a property changed notification on the MaxDate property:
OnPropertyChanged("MaxDate");
Hopefully MaxDate is a property in your view model. If you are binding directly to the DatePicker's SelectedDate property then you won't be able to trigger the property changed notification without actually changing the date. I recommend just having the MaxDate and MinDate properties in your view model.