i was wondering if i can change the display style of an appointment in radscheduleview like shown in the attached screenshot? Is it
possible?
The default appointment style does only display the subject of an appointment in the week view for example. In my opinion, this is a waste of useful display space and my goal is to display additional information like the location, resources or category of an appointment.
I looked through the examples and API documentation but didn't found any hint or solution for this problem.
thanks in advance,
best regards
Matthias
9 Answers, 1 is accepted
Here's my code.
Public Class AppointmentStyleSelector Inherits OrientedAppointmentItemStyleSelector Private _horizontalAppointmentStyle As Style Public Property HorizontalAppointmentStyle() As Style Get Return _horizontalAppointmentStyle End Get Set(value As Style) _horizontalAppointmentStyle = value End Set End Property Private _verticalAppointmentStyle As Style Public Property VerticalAppointmentStyle() As Style Get Return _verticalAppointmentStyle End Get Set(value As Style) _verticalAppointmentStyle = value End Set End Property Public Overrides Function SelectStyle(item As Object, container As DependencyObject, activeViewDefinition As ViewDefinitionBase) As Style Dim appointment As IAppointment = TryCast(item, IAppointment) If appointment Is Nothing Then Return MyBase.SelectStyle(item, container, activeViewDefinition) End If If activeViewDefinition.GetOrientation() = Orientation.Horizontal Then Return Me.HorizontalAppointmentStyle Else Return Me.VerticalAppointmentStyle End If End Function End ClassAnd the corresponding XAML code:
<Style x:Key="HorizontalAppointmentStyle" TargetType="telerik:AppointmentItem"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF46384B" Offset="0.998"/> <GradientStop Color="#FFBA9DC2" Offset="0.007"/> </LinearGradientBrush> </Setter.Value> </Setter> </Style> <Style x:Key="VerticalAppointmentStyle" TargetType="telerik:AppointmentItem"> <Setter Property="ContentTemplateSelector"> <Setter.Value> <telerik:AppointmentItemContentTemplateSelector> <telerik:AppointmentItemContentTemplateSelector.DefaultTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <TextBlock TextWrapping="Wrap" Text="{Binding Subject}" TextTrimming="WordEllipsis"/> <TextBlock TextWrapping="Wrap" Text="{Binding Appointment.Description}" TextTrimming="WordEllipsis"/> <TextBlock TextWrapping="Wrap" Text="{Binding Appointment.Location}" TextTrimming="WordEllipsis"/> </StackPanel> </DataTemplate> </telerik:AppointmentItemContentTemplateSelector.DefaultTemplate> </telerik:AppointmentItemContentTemplateSelector> </Setter.Value> </Setter> </Style> <Calendar:AppointmentStyleSelector x:Key="AppointmentItemStyleSelector" HorizontalAppointmentStyle="{StaticResource HorizontalAppointmentStyle}" VerticalAppointmentStyle="{StaticResource VerticalAppointmentStyle}" />thanks for your help!
Can you change the SelectStyle method to the following code:
...If activeViewDefinition.GetOrientation() = Orientation.Horizontal ThenReturn Me.VerticalAppointmentStyle
ElseReturn Me.HorizontalAppointmentStyle
End IfHope this helps.
Regards,
George
the Telerik team
thanks for your reply.
I've tested your code snippet but that doesn't work for me. The 'resize' indicators are still positioned on the left and right side of the appointment.
I really have no idea whats causing this problem.
best regards
Matthias
We took some time to investigate the issue and we found a bug in our code. We will try to fix it for our next internal build. The issue is logged in our PITS and you can track it here - http://www.telerik.com/support/pits.aspx#/public/wpf/9768. I am glad to update your telerik points.
George
the Telerik team
Hi,
I have check this issue now again with the newst version of RadScheduleView but it still looks the same.
After some search I found that you often recommend to copy the ScheduleView.xaml, as this is the only way to access the styles in it. For some resones it is not possible to access the "AppointmentItemVerticalControlTemplate" with TryFindResource. Not even the "RadScheduleViewStyle" can be found. Even though it is used by the RadScheduleView.
To avoid copying your 4700 line long resource dictionary I have solve the issue now on this way:
<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Telerik.Windows.Controls.ScheduleView;component/Themes/Office/Black/ScheduleView.xaml"/> </ResourceDictionary.MergedDictionaries> <Style x:Key="VerticalAppointmentStyle" TargetType="telerik:AppointmentItem"> <Setter Property="Template" Value="{DynamicResource AppointmentItemVerticalControlTemplate}" /> <!-- your setters--> </Style> <Style x:Key="HorizontalAppointmentStyle" TargetType="telerik:AppointmentItem"> <!-- Horizontal works fine anyway. --> </Style> <Calendar:AppointmentStyleSelector x:Key="AppointmentItemStyleSelector" HorizontalAppointmentStyle="{StaticResource HorizontalAppointmentStyle}" VerticalAppointmentStyle="{StaticResource VerticalAppointmentStyle}" /> </ResourceDictionary></UserControl.Resources><telerik:RadScheduleView
AppointmentStyleSelector="{StaticResource AppointmentItemStyleSelector}"... />
First I reference the ScheduleView.xaml directly from your assembly, so I dont have to a copy it.
Second I add the AppointmentItemVerticalControlTemplate to the vertical style.
best regards,
David
Copying ScheduleView.xaml is only recommended when you are modifying a theme different than the default one. If you are editing the Office Black theme, you do not need to copy the entire RadScheduleView xaml, you just need the part you wish to customize.
However, if the part you wish to customize (in your case, the AppointmentItemVerticalControlTemplate) is from a theme different than the default, then you should base your custom style on the theme you are using.
You can use NoXaml Binaries together with implicit styles to apply a theme. Then, append in App.xaml your custom style and base it on the theme you are using. More details on implicit styling and the process of basing a style on a theme can be found here.
The bug with the OrientedAppointmentItemStyleSelector should be fixed since 2012 Q1 SP1 in March. If you are still experiencing issues, please share a reproducable project which we can test.
All the best,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi Dani,
I have create a sample, showing what I want to modify.
RadScheduleViewWPF.zip
Also I have attach a screenshot. It shows that the Resize grip is on the wrong side.
Maybe you can verify if this is still the bug or if I do something wrong.
best regards,
David
When using the AppointmentItemStyleSelector, you need to copy and modify the entire selector. Providing only one of the two styles from the selector results in broken orientation.
Anyway, you do not need the style selector if what you wish to customize is only the content template of vertical appointments (AppointmentItemStyleSelector includes quite some amount of xaml; you could avoid that). You can use the AppointmentItemContentTemplateSelector. By default this selector has a single default template. You need to inherit it and create your own custom AppointmentItemContentTemplateSelector in order to make it orientation-aware and provide a ContentTemplate for the vertically oriented appointments only.
I hope this will be helpful.
Regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.