This is a migrated thread and some comments may be shown as answers.

Dynamic styles on TimeRulerItem

1 Answer 67 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Myles
Top achievements
Rank 1
Myles asked on 05 Jul 2012, 01:45 PM
Hi,

I wondered if anyone out there has managed to dynamically change styles on the TimeRulerItems.  I know that you can initially set different styles using OrientedTimeRulerItemStyleSelector but this doesn't appear to meet my needs.  I am trying to dynamically change the BorderBrush of the TimeRulerItems based upon the number of appointments currently in the associated time slot.  For example, if there are more than 10 appointments that fall within any given 10 minute slot I want the BorderBrush of the associated TimeRulerItem to appear red.  This style needs to dynamically change according to this condition.

Regards

Myles

1 Answer, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 06 Jul 2012, 06:42 PM
Hi Miles,

You could change the Styles from the code behind. Using logic to determine your tolerances, then set and assign the Style you want. The setter looks like this

public class CustomTimeRulerItemStyleSelector : OrientedTimeRulerItemStyleSelector
    {
        public Style MinorTickLineStyle { get; set;}
        public Style MajorTickLineStyle { get; set; }
 
        public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
        {
            if (container is TimeRulerLine)
            {
                TickData tick = item as TickData;
                if (tick.Type == TickType.Major)
                {
                    return MajorTickLineStyle;
                }
                return MinorTickLineStyle;
            }
            return base.SelectStyle(item, container, activeViewDeifinition);
        }    }


You can make a couple different styles and then assign them accordingly. This link will bring you to the documentation on how to create and set custom styling on the TimeRulerItems.

Good Luck,
Lancelot
Tags
ScheduleView
Asked by
Myles
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Share this question
or