Dynamic styles on TimeRulerItem

2 posts, 0 answers
  1. Myles
    Myles avatar
    13 posts
    Member since:
    May 2012

    Posted 05 Jul 2012 Link to this post


    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.


  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2012 Link to this post

    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,
Back to Top