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

Setting TimeSlot colors

1 Answer 57 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Terry Newton
Top achievements
Rank 1
Terry Newton asked on 17 Apr 2010, 02:49 AM

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")

                        Else

                              '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")

                              Else

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

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

                              End If

                        End If

                  Next

            End If

      End Sub

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

            <Setter

             Property="Template"

             >

                  <Setter.Value>

                        <ControlTemplate TargetType="tkControlsScheduler:TimeSlotItem">

                              <Border x:Name="PART_ContentHost"

                                    Background="PaleGreen"

                                    Margin="0,0,1,1"

                                          MinHeight="10">

                                    <tkControls:CommandManager.InputBindings>

                                          <tkControls:InputBindingCollection>

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

                                          </tkControls:InputBindingCollection>

                                    </tkControls:CommandManager.InputBindings>

 

                                    <msWindows:VisualStateManager.VisualStateGroups>

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

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

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

                                                      <Storyboard>

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

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

                                                            </ObjectAnimationUsingKeyFrames>

                                                      </Storyboard>

                                                </msWindows:VisualState>

                                          </msWindows:VisualStateGroup>

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

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

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

                                                      <Storyboard>

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

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

                                                            </ObjectAnimationUsingKeyFrames>

                                                      </Storyboard>

                                                </msWindows:VisualState>

                                          </msWindows:VisualStateGroup>

                                    </msWindows:VisualStateManager.VisualStateGroups>

 

                              </Border>

 

                        </ControlTemplate>

                  </Setter.Value>

            </Setter>

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

      </Style>

 

1 Answer, 1 is accepted

Sort by
0
Teodor
Telerik team
answered on 21 Apr 2010, 12:38 PM
Terry Newton,

Thank you for contacting us.

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

http://www.telerik.com/help/silverlight/radscheduler-styles-templates-timeslot-template-selector.html

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

Best wishes,
Teodor
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.
Tags
Calendar
Asked by
Terry Newton
Top achievements
Rank 1
Answers by
Teodor
Telerik team
Share this question
or