Setting TimeSlot colors

2 posts, 0 answers
  1. Terry Newton
    Terry Newton avatar
    21 posts
    Member since:
    Oct 2009

    Posted 16 Apr 2010 Link to this post

    I am dynamically altering the background color via applying a style to the timeslotitems at run time during a drag operation using information from the drag context to set the eligible drop target timeslot colors.  This works but messes up the prior behaviours of selecting a day via a click and having the color change and the mouseover stuff.  I modeled this on the OneWeekDayStyle referenced in your examples that use a converter(the converter solution does not know the timewindow determined by the drag object, so that solution will not work without substantial modification).  I tried using your style to restore unsuccessfully, but that may still be a usefull approach.  I am including the main logic and the main style to show what I did.


    I would like advice on how to correct my approach to avoid breaking the desired behaviours.


    Thanks for any possible help!


    Private Sub SetDragBackground(ByVal otime As Time)

                If Me.Mode = CalendarMode.Day Or Me.Mode = CalendarMode.Week Then

                      Dim smsg As String = ""

                      Dim oTimeSlotItems As IList(Of TimeSlotItem) = ctlScheduler.ChildrenOfType(Of TimeSlotItem)()

                      For Each oTimeSlotItem In oTimeSlotItems

                            smsg = ""

                            If Me.DragAssignment IsNot Nothing AndAlso Me.DragAssignment.IsTimeAcceptable(oTimeSlotItem.TimeSlot.Start, oTimeSlotItem.TimeSlot.End, smsg) AndAlso Me.DragAssignment.IsDateAcceptable(oTimeSlotItem.TimeSlot.Start, oTimeSlotItem.TimeSlot.End, smsg) AndAlso Not (oTimeSlotItem.TimeSlot.Start.Date < Today.Date And Not CanScheduleInPast) Then

                                  oTimeSlotItem.Style = System.Windows.Application.Current.Resources("StyleTimeSlotEligible")


                                  'set the default background color

                                  If oTimeSlotItem.TimeSlot.Start.Date = Me.SelectedDay.Date Then

                                        'oTimeSlotItem.Style = System.Windows.Application.Current.Resources("OneWeekDayStyle")

                                        oTimeSlotItem.Style = System.Windows.Application.Current.Resources("StyleTimeSlotSelectedDay")


                                        'oTimeSlotItem.Style = System.Windows.Application.Current.Resources("OneWeekDayStyle")

                                        oTimeSlotItem.Style = System.Windows.Application.Current.Resources("StyleTimeSlotIneligible")

                                  End If

                            End If


                End If

          End Sub

          <Style x:Key="StyleTimeSlotEligible" TargetType="tkControlsScheduler:TimeSlotItem">





                            <ControlTemplate TargetType="tkControlsScheduler:TimeSlotItem">

                                  <Border x:Name="PART_ContentHost"






                                                    <tkControls:MouseBinding MouseAction="LeftDoubleClick" Command="tkControlsScheduler:RadSchedulerCommands.CreateAppointment"  />





                                              <msWindows:VisualStateGroup x:Name="CommonStates">

                                                    <msWindows:VisualState x:Name="Normal" />

                                                    <msWindows:VisualState x:Name="MouseOver" >


                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentHost" Storyboard.TargetProperty="Background" Duration="0">

                                                                      <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MonthTimeSlotItemOverBrush}"/>





                                              <msWindows:VisualStateGroup x:Name="SelectionStates">

                                                    <msWindows:VisualState x:Name="Unselected"/>

                                                    <msWindows:VisualState x:Name="Selected">


                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentHost" Storyboard.TargetProperty="Background" Duration="0">

                                                                      <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MonthTimeSlotItemSelectedBrush}"/>












                <Setter Property="Background" Value="PaleGreen"/>



  2. Teodor
    Teodor avatar
    501 posts

    Posted 21 Apr 2010 Link to this post

    Terry Newton,

    Thank you for contacting us.

    Actually, the best way to customize TimeSlot appearance is via the TimeSlotTemplateSelector property. More on this here:

    Hope this helps. Let us know if you have other queries.

    Best wishes,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
Back to Top