24 h Format for Drag Over Visual

1 Answer 39 Views
DragAndDrop ScheduleView
Marko
Top achievements
Rank 2
Iron
Marko asked on 01 Oct 2024, 11:15 AM
When dragging over a timeslot in RadScheduleView. The Drag over visual showing the start and end times are always shown in 12h Format. Even though my PC locale is set to 24h format.


When dragging over the 15:00 slot, It shows 3PM and 5PM instead of 15:00 and 17:00. The timeruler correctly shows the same format as my PC locale but the drag over visual seems to always be 12h.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 02 Oct 2024, 02:43 PM

Hello Marko,

To achieve this requirement, extract the default ControlTemplate from the Style with x:Key="DragDropHighlightStyle" for the HighlightItem element. Then, you can customize the StringFormat property's value of the Binding instance for the Text property of the TextBlock elements with x:Name="StartTextBox" and x:Name="EndTextBox". Then, create a new Style that targets the HighlightItem element and set the modified ControlTemplate to its Template property. Finally, set this newly created Style to the DragDropHighlightStyle property of RadScheduleView.

The following code snippets show what I have in mind:

<Application.Resources>
        <Style x:Key="CustomDragDropHighlightStyle" TargetType="telerik:HighlightItem">
            <Setter Property="Background" Value="{telerik:Windows8Resource ResourceKey=StrongBrush}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <Border Background="{TemplateBinding Background}" Opacity="0.1"/>
                            <Path Data="M0,0 L2,0 L0,2 z"
                                  Height="4"
                                  Width="4"
                                  Margin="1"
                                  Stretch="Fill"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Top"
                                  Fill="{telerik:Windows8Resource ResourceKey=MarkerBrush}"/>
                            <TextBlock x:Name="StartTextBox"
                                       Margin="4 2"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       Text="{Binding ActualStart,StringFormat={}{0:HH:00}}"
                                       Foreground="{telerik:Windows8Resource ResourceKey=MarkerBrush}"/>
                            <Path Data="M2,0 L2,2 L0,2 z"
                                  Height="4"
                                  Width="4"
                                  Stretch="Fill"
                                  Margin="1"
                                  HorizontalAlignment="Right"
                                  VerticalAlignment="Bottom"
                                  Fill="{telerik:Windows8Resource ResourceKey=MarkerBrush}"/>
                            <TextBlock x:Name="EndTextBox"
                                       Margin="4 2"
                                       HorizontalAlignment="Right"
                                       VerticalAlignment="Bottom"
                                       Text="{Binding ActualEnd,StringFormat={}{0:HH:00}}"
                                       Foreground="{telerik:Windows8Resource ResourceKey=MarkerBrush}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
</Application.Resources>
<telerik:RadScheduleView DragDropHighlightStyle="{StaticResource CustomDragDropHighlightStyle}" DataContext="{StaticResource MyViewModel}" AppointmentsSource="{Binding Appointments}">
    <telerik:RadScheduleView.ViewDefinitions>
        <telerik:DayViewDefinition />
    </telerik:RadScheduleView.ViewDefinitions>
</telerik:RadScheduleView>

The following image showcases the produced result:


With this being said, could you give this suggestion a try and let me know how it goes?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Marko
Top achievements
Rank 2
Iron
commented on 04 Oct 2024, 08:52 AM

Hi Stenly, I tried your suggestion and it worked great. Thank you
Tags
DragAndDrop ScheduleView
Asked by
Marko
Top achievements
Rank 2
Iron
Answers by
Stenly
Telerik team
Share this question
or