RadDateTimePicker What I want to ask is that I can choose the time on my computer, but I can't choose the time on other computers

0 Answers 41 Views
DateTimePicker TimePicker
li
Top achievements
Rank 1
Iron
li asked on 29 Apr 2022, 02:11 AM

<Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="42"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.1*"></ColumnDefinition>
                <ColumnDefinition Width="3.5*"></ColumnDefinition>
                <ColumnDefinition Width="0.8*"></ColumnDefinition>
                <ColumnDefinition Width="3.5*"></ColumnDefinition>
                <ColumnDefinition Width="2*"></ColumnDefinition>
                <ColumnDefinition Width="0.1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid Grid.Row="0" Grid.Column="1">
                <telerikInput:RadDateTimePicker SpinnerFormat="yyyy-MM-dd HH:mm:ss" x:Name="StarDateTime" 
                                PlaceholderTemplate="{StaticResource placeholderTemplateStar}"
                                DisplayTemplate="{StaticResource displayTemplate}">
                    <telerikInput:RadDateTimePicker.SelectorSettings>
                        <telerikInput:PickerPopupSelectorSettings HeaderTemplate="{StaticResource headerTemplate}" 
                                                  FooterTemplate="{StaticResource footerTemplate}" />
                    </telerikInput:RadDateTimePicker.SelectorSettings>
                </telerikInput:RadDateTimePicker>
            </Grid>
            <Grid Grid.Row="0" Grid.Column="2">
                <Label VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="---" />
            </Grid>
            <Grid Grid.Row="0" Grid.Column="3">
                <telerikInput:RadDateTimePicker SpinnerFormat="yyyy-MM-dd HH:mm:ss" x:Name="EndDateTime" 
                                PlaceholderTemplate="{StaticResource placeholderTemplateEnd}"
                                DisplayTemplate="{StaticResource displayTemplate}">
                    <telerikInput:RadDateTimePicker.SelectorSettings>
                        <telerikInput:PickerPopupSelectorSettings HeaderTemplate="{StaticResource headerTemplate}" 
                                                  FooterTemplate="{StaticResource footerTemplate}"/>
                    </telerikInput:RadDateTimePicker.SelectorSettings>
                </telerikInput:RadDateTimePicker>
            </Grid>
            <Grid Grid.Row="0" Grid.Column="4">
                <telerikInput:RadButton Text="计算" CornerRadius="20" Clicked="RadButton_Clicked" Style="{StaticResource BtnSubStyle}" />
            </Grid>

        </Grid>

 

--样式

<ControlTemplate x:Key="placeholderTemplateStar">
        <Label Text="请选择开始时间" 
           FontAttributes="Bold" 
           BackgroundColor="Black" 
           HeightRequest="50"
           VerticalTextAlignment="Center"
           HorizontalTextAlignment="Center">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{TemplateBinding ToggleCommand}" />
            </Label.GestureRecognizers>
        </Label>
    </ControlTemplate>
    <ControlTemplate x:Key="placeholderTemplateEnd">
        <Label Text="请选择结束时间" 
           FontAttributes="Bold" 
           BackgroundColor="Black" 
           HeightRequest="50"
           VerticalTextAlignment="Center"
           HorizontalTextAlignment="Center">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{TemplateBinding ToggleCommand}" />
            </Label.GestureRecognizers>
        </Label>
    </ControlTemplate>
    <ControlTemplate x:Key="displayTemplate">
        <Label Text="{TemplateBinding DisplayString}" 
           TextColor="Black" 
           HeightRequest="50"
           VerticalTextAlignment="Center"
           HorizontalTextAlignment="Center">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{TemplateBinding ToggleCommand}" />
            </Label.GestureRecognizers>
        </Label>
    </ControlTemplate>

<ControlTemplate x:Key="headerTemplate">
        <Label Text="{TemplateBinding HeaderLabelText}" 
           TextColor="Black"
           VerticalTextAlignment="Center"
           HorizontalTextAlignment="Center"/>
    </ControlTemplate>
    <ControlTemplate x:Key="footerTemplate">
        <StackLayout Orientation="Horizontal" Spacing="0" HorizontalOptions="FillAndExpand">
            <Button Text="{TemplateBinding CancelButtonText}" 
                TextColor="Black"
                BackgroundColor="Transparent"
                Command="{TemplateBinding CancelCommand}" />
            <Button Text="{TemplateBinding AcceptButtonText}" 
                TextColor="Black"
                BackgroundColor="Transparent"
                Command="{TemplateBinding AcceptCommand}" />
        </StackLayout>

    </ControlTemplate>

--英文改为中文

public class CustomDateTimePickerLocalizationManager: TelerikLocalizationManager
{
        public override string GetString(string key)
        {

            if (key == "DateTimePicker_Popup_HeaderLabelText")
                return "Datum und Uhrzeit Picker";
            if (key == "DateTimePicker_PlaceholderLabelText")
                return "Datum und Uhrzeit auswählen";
            if (key == "Picker_AmPmSpinnerHeaderLabelText")
                return "am/pm";
            if (key == "Picker_DaySpinnerHeaderLabelText")
                return "日";
            if (key == "Picker_HourSpinnerHeaderLabelText")
                return "小时";
            if (key == "Picker_MinuteSpinnerHeaderLabelText")
                return "分";
            if (key == "Picker_SecondSpinnerHeaderLabelText")
                return "秒";
            if (key == "Picker_MonthSpinnerHeaderLabelText")
                return "月";
            if (key == "Picker_YearSpinnerHeaderLabelText")
                return "年";
            if (key == "Picker_Popup_AcceptButtonText")
                return "选择";
            if (key == "Picker_Popup_CancelButtonText")
                return "关闭";

            return base.GetString(key);
        }
    }

--后端

InitializeComponent();
            TelerikLocalizationManager.Manager = new CustomDateTimePickerLocalizationManager();
            StarDateTime.MinimumDate = DateTime.Now.AddYears(-10);
            EndDateTime.MinimumDate = DateTime.Now.AddYears(-10);
            StarDateTime.Date = DateTime.Now.AddYears(-1);
            EndDateTime.Date = DateTime.Now;
Didi
Telerik team
commented on 29 Apr 2022, 01:00 PM

Hi, 

 Could you please share what is the exact scenario you want to achieve?

I do not understand this sentence: I can choose the time on my computer, but I can't choose the time on other computers. How do you want to choose the time on other computer?

DateTimePicker documentation: 
All properties datetime picker provides are described in the documentation: https://docs.telerik.com/devtools/xamarin/controls/datetimepicker/datetime-picker-overview

li
Top achievements
Rank 1
Iron
commented on 05 May 2022, 04:33 AM

I need two time controls, a start time and an end time. When I use this control, clicking this control will not pop up the selection time box. In the past, I can select the time locally. Other computers use my page and the select time box will not pop up. Now it's not even local. Click the control and the time selection box will not pop up
Didi
Telerik team
commented on 05 May 2022, 05:34 AM

Hi, 

Regarding this: When I use this control, clicking this control will not pop up the selection time box. - on my side the popup opens when I click on the DateTimePicker. 

Next Steps: Please open a support ticket and attach sample repro project. I am not sure I understood the issue you have with the DateTimePicker control. Also attach a video of the behavior and add a step to reproduce the issue.

Additional info: In general, you can select time from the date time picker. For example, you can use the datetime picker in time mode when setting the DisplayStringFormat="HH:mm:ss". Here is an example: 
https://docs.telerik.com/devtools/xamarin/controls/datetimepicker/datetime-picker-key-features#time-picker-mode 

The popup displays only time spinners. and you can select time. If you want to add a date range here are the properties you can use https://docs.telerik.com/devtools/xamarin/controls/datetimepicker/datetime-picker-key-features#date-range 

No answers yet. Maybe you can help?

Tags
DateTimePicker TimePicker
Asked by
li
Top achievements
Rank 1
Iron
Share this question
or