Hi,
We are using XAM Calendar, we want to add background and foreground color for selected Dates. Suppose If I select dates 4-22-2016, 4-23-2014, 4-24-2016 from XAM Calendar , then we want to change background and foreground color of these selected dates.
Please let us aware,
Thanks.
Hello Kanwar,
I recommend using the XamMonthCalendar and using a trigger to manipulate the IsSelected property of the CalendarDayStyle
eg.
<Custom:XamMonthCalendar HorizontalAlignment="Left" VerticalAlignment="Top" Margin="290,60,0,0"> <Custom:XamMonthCalendar.CalendarDayStyle> <Style TargetType="{x:Type Custom:CalendarDay}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="Purple"/> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="True"/> <Condition Property="IsWorkday" Value="False"/> </MultiTrigger.Conditions> <MultiTrigger.Setters> <Setter Property="Opacity" Value="0.5"/> <Setter Property="Background" Value="Purple"/> </MultiTrigger.Setters> </MultiTrigger> </Style.Triggers> </Style> </Custom:XamMonthCalendar.CalendarDayStyle> </Custom:XamMonthCalendar>
Let me know if you have any questions regarding this matter.<[code
Thanks for your wonderful support. But here our requirement is that dynamically we want to change background and foreground color for selected dates.
In other words we want to bind BackGround and Foreground color in XAMCalendar and In ViewModel we will check if dates are selected then we can add background and foreground color.
Thanks
Do you have a condition where you are checking for the start and end date with a field in your view model that approves whether or not you have the color affect? If not, then the CalendarDay will be repurposed and it won't know the difference when to display the color on the designated dates.
Like the trigger I listed above you will most likely need to also bind to the StartDate property with your data in your view model to ensure that only the days you want (based on some condition) are updated accordingly. The following trigger only updates the backcolor for April 29th:
<MultiTrigger> <MultiTrigger.Conditions> <Condition Property="StartDate" Value="4/29/2016" /> <Condition Property="IsSelected" Value="True"/> <Condition Property="IsWorkday" Value="True"/> </MultiTrigger.Conditions> <MultiTrigger.Setters> <Setter Property="Opacity" Value="0.5"/> <Setter Property="Background" Value="Purple"/> </MultiTrigger.Setters> </MultiTrigger>
XAMCalendar Days style not finding any StartDate Property. We want to change background color of Calendar Days (Provided By specific range). Like If I select 4/28/2016 as start Date and 7/28/2016 as end Date. In this condition all dates(start from 4/28/2016 and End from 7/28/2016 ) background color should be change.
Can you please send me a sample of where you are stuck at and I'll assist you. Let me know if you have any additional questions.
I have attached sample project . Scenario is: Initially 2 Months Calendar is showing for April and May. when we select start Date from DatePicker (April Date) and
EndDate is any Suppose like June.
Output will be: Initially background and ForeGround Style will not change for April and May Month but when we scroll for June then the background and foreground color will be change.
Okay, so it appears that you want to update the selected appearance immediately after selecting an end date. Unfortunately performing UpdateLayout didn't work and I too noticed the style takes affect only when the months changed aka recycled. It looks like you are going to still need to write a trigger to apply the custom CustomCalendarDayStyle after the end date is selected. I don't have any custom logic to perform this at this time.