Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1465
Colour each timeslot per condition.
posted

Hi,

 

I was wondering if it is possible to get a list of the timeslotpresenters from the dayview. Basically I need to loop through all the timeslots of a day and colour each timeslot a different colour depending on specific conditions.  I have looked at all the current questions on this forum regarding colouring of timeslots but have not found one that answers this question.

Any help would be appreciated.

thanks in advance

 

 

 

 

  • 35319
    Verified Answer
    posted

    Hello Anne,

     

    I have been looking into your question and the easiest way to achieve the desired functionality is to use a style for the TimeslotPresenter and setting the ‘Background’ on specific condition using value converter like e.g. :

     

    <Style TargetType="igSchedulePrim:TimeslotPresenter">

                    <Setter Property="Template">

                        <Setter.Value>

                            <ControlTemplate TargetType="igSchedulePrim:TimeslotPresenter">

                                <Grid>

                                    <Border x:Name="Border"

                                                    BorderBrush="{TemplateBinding ComputedBorderBrush}"

                                                    BorderThickness="{Binding Path=Orientation, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource tsOrientationToThicknessConverter}}"

                                                    Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource con}}"

                                                    Padding="{TemplateBinding Padding}"

                                                    igPrim:XamlHelper.SnapsToDevicePixels="True">

                                    </Border>

                                    <Border x:Name="DayBorder"

                                                    BorderBrush="{TemplateBinding DayBorderBrush}"

                                                    BorderThickness="{TemplateBinding DayBorderThickness}"

                                                    Visibility="{TemplateBinding DayBorderVisibility}"

                                                    igPrim:XamlHelper.SnapsToDevicePixels="True">

                                    </Border>

                                </Grid>

                            </ControlTemplate>

                        </Setter.Value>

                    </Setter>

                </Style>

     

     

        public class MyConverter : IValueConverter

        {

            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

            {

                DateTime start = (value as TimeRangePresenterBase).Start;

                DateTime end = (value as TimeRangePresenterBase).End;

     

                if (start.Hour == 9 && start.Minute == 15 && end.Hour == 9 && end.Minute == 30)

                {

                    return Brushes.Red;

                }

     

                if (start.Hour == 15 && start.Minute == 30 && end.Hour == 15 && end.Minute == 45)

                {

                    return Brushes.Yellow;

                }

     

                return Brushes.Transparent;

            }

     

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

            {

                return value;

            }

        }

     

    Let me know, if you need any further assistance on this matter.