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

Change background cell color

hi.... How do I change the background cell color in Calendar? I'm trying to use with Converter with no success...
this is what I have so far:

        public object Convert(object value, Type targetType, object parameter, CultureInfo language)
        {
            var appointments = parameter as Dictionary<DateTime, Appointment>;
            var date = (DateTime)value;
            if (appointments != null)
            {
                if (appointments.ContainsKey(date))
                {
                    return Colors.Magenta;
                }
            }

            return null;
        }

Data template:

<DataTemplate x:Key="Celltemplate">
            <Grid>
                <TextBlock
                    Text="{Binding Converter={StaticResource Converter}, ConverterParameter={StaticResource Appointments}}"
                    Foreground="{Binding Converter={StaticResource ColorConverter}, ConverterParameter={StaticResource Appointments}}"
                    VerticalAlignment="Top"
                    HorizontalAlignment="Right"
                    Margin="3"
                    FontSize="10"
                    TextWrapping="Wrap"/>
                <TextBlock
                    Text="{Binding Day}"
                    VerticalAlignment="Bottom"
                    Margin="3"/>
            </Grid>
        </DataTemplate>

2 Replies

WM Washington Morais May 12, 2014 02:18 PM UTC

Ok, I found the solution. I hope it helps someone.

The problem was with the return of the Converter function. It must be return new SolidColorBrush(Colors.Magenta); instead of return Colors.Magenta;.


VV Vignesh V Syncfusion Team May 13, 2014 09:23 AM UTC

Hi Morais,

Thanks for your update.      
We are glad to know that you have found the solution.Please let us know if you need further assistance.

Regards,
Vignesh V

Loader.
Live Chat Icon For mobile
Up arrow icon