Setting time range for time selector

8 posts, 0 answers
  1. Auvo
    Auvo avatar
    34 posts
    Member since:
    Jul 2011

    Posted 25 Sep 2015 Link to this post

    Hi,

     

    How can I set the time range for time selector in RadTimePicker?

    User need to select time between 06:30 - 09:00 with time range 10min

    Without that range, time selector looks quite messy

     

    I tried to use DisplayDateStart and -end properties but it did not help

     

    FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(Telerik.Windows.Controls.RadTimePicker));
    spFactory.Name = "factory";
    spFactory.SetValue(Telerik.Windows.Controls.RadTimePicker.TimeIntervalProperty, new TimeSpan(0, 10, 0));
    spFactory.SetValue(Telerik.Windows.Controls.RadTimePicker.DisplayDateStartProperty, new DateTime() + new TimeSpan(6, 30, 0));
    spFactory.SetValue(Telerik.Windows.Controls.RadTimePicker.DisplayDateEndProperty, new DateTime() + new TimeSpan(9, 0, 0));
    template.VisualTree = spFactory;
    template.Seal();

     

    Regards,

    Auvo

  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 29 Sep 2015 Link to this post

    Hello Auvo,

    In order to limit the times that could be selected with the desired interval between the time slots you need to use the StartTime and EndTime properties. By setting them to "06:30" and "09:00" the needed limitation will be achieved and the TimeInterval property should be set to "0:10:0" in order to specify the needed interval.

    We hope this will help you.

    Regards,
    Nasko
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Auvo
    Auvo avatar
    34 posts
    Member since:
    Jul 2011

    Posted 30 Sep 2015 in reply to Nasko Link to this post

    Nice and simply solution, it's works :)

     

    Thank's,

    Auvo

  5. Andrew
    Andrew avatar
    9 posts
    Member since:
    Aug 2014

    Posted 03 Aug in reply to Nasko Link to this post

    When I set the start and end time like this: StartTime="04:01" EndTime="13:59" it works as expected.

    When I bind those values (see code below) and the converter return the exact same values as above 04:01 and 13:59 nothing happens and the start and end time stays at 12:00 am to 12:00 pm.  Any ideas? 

     

    <telerik:RadDateTimePicker.StartTime>
    <MultiBinding Converter="{StaticResource DatesToDateConverter}" ConverterParameter="startT">
    <Binding Path="ActualStart"/>
    <Binding Path="ActualEnd"/>
    <Binding Path="Occurrence.Appointment.Status"/>
    </MultiBinding>
    </telerik:RadDateTimePicker.StartTime>
    <telerik:RadDateTimePicker.EndTime>
    <MultiBinding Converter="{StaticResource DatesToDateConverter}" ConverterParameter="endT">
    <Binding Path="ActualStart"/>
    <Binding Path="ActualEnd"/>
    <Binding Path="Occurrence.Appointment.Status"/>
    </MultiBinding>
    </telerik:RadDateTimePicker.EndTime>

  6. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 04 Aug Link to this post

    Hi Andrew,

    We are not aware of the observed by you issue. Could you please provide us some additional information about your scenario? We have noticed that you are binding also to the "Occurrence.Appointment.Status" property - is the DateTimePicker placed inside ScheduleView or inside one of the Dialogs of RadScheduleView.

    Also, providing a code-snippet of the DatesToDateConverter will also be of great help for our further investigation?
     
    We are looking forward to hearing from you.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Andrew
    Andrew avatar
    9 posts
    Member since:
    Aug 2014

    Posted 04 Aug in reply to Nasko Link to this post

    Nasko,

    Yes, you are correct that the code is modifying (and inside) the Telerik.Windows.Controls.ScheduleView.xaml file.  I am changing how the dialog that lets you set a start and end time for event works in the grid: (<Grid x:Name="Details" Grid.Row="2" Margin="6">)

    Here is the DatesToDateConverter code:

    Public Class DatesToDateConverter
    Implements IMultiValueConverter
    Public Function Convert(value() As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IMultiValueConverter.Convert
    Dim startDate As DateTime = value(0)
    Dim endDate As DateTime = value(1)
    Dim status As globals.PTOStatus = [Enum].Parse(GetType(globals.PTOStatus), value(2))
    Dim param As String = parameter

    Select Case status
    Case PTOStatus.NotSet
    Return startDate.AddDays(7)
    Case Else
    If param = "start" Then
    Return endDate
    ElseIf param = "end" Then
    Return startDate
    ElseIf param = "startT" Then
    Return "04:01" 'startDate.AddMinutes(1).ToString("HH:mm") 'allow them to scale down the request to 1 min
    ElseIf param = "endT" Then
    Return "13:59" 'endDate.AddMinutes(-1).ToString("HH:mm")
    Else
    Return startDate.AddDays(7) 'numToAdd)
    End If
    End Select
    End Function
    Public Function ConvertBack(value As Object, targetTypes() As Type, parameter As Object, culture As Globalization.CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
    Throw New NotImplementedException
    End Function
    End Class

    Thanks so much for your help!

    Andrew

  8. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 05 Aug Link to this post

    Hello Andrew,

    Your converter returns strings when the passed parameter is "startT" or "endT". As the StartTime and EndTime properties are of type TimeSpan the return value should be TimeSpan:
    Public Function Convert(ByVal values() As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IMultiValueConverter.Convert
        If parameter.ToString().Equals("startT") Then
            'Return "04:01"
            Return New TimeSpan(4, 1, 0)
        Else
            'Return "13:59"
            Return New TimeSpan(13, 59, 0)
        End If
    End Function

    Could you please give it a try and let us know if it worked for you?

    Hope this helps.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  9. Andrew
    Andrew avatar
    9 posts
    Member since:
    Aug 2014

    Posted 05 Aug in reply to Nasko Link to this post

    Everything works as expected now that I am using a timespan - thanks for the help!
Back to Top
UI for WPF is Visual Studio 2017 Ready