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>