This is a migrated thread and some comments may be shown as answers.

How To Disable TextBox Input

2 Answers 152 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
KO
Top achievements
Rank 1
KO asked on 12 Jan 2011, 08:43 PM
Greetings:

If I add a collection of valid time values using the ClockItemsSource property, how can I make the TimePicker only consider the added times as valid? For example, if I add the times 8:00 AM, 11:00 AM and 2:00 PM, I consider all times except those three times as invalid data. Yet the user can type the value 123 and the control will accept the time 12:03 PM without question.

I would like to simply set the TextBox portion of the TimePicker to read-only. This way I would have complete control over valid values by letting the user select them from the dropdown. Can this be done? If not, can you recommend an easy way to prevent the user from entering invalid times?

Thank you,

KO

2 Answers, 1 is accepted

Sort by
0
KO
Top achievements
Rank 1
answered on 12 Jan 2011, 08:53 PM
I came across RadClock immediately after starting this thread. I see how I could use RadClock with my own TextBox. However, if there is an easy way to simply disable the RadTimePicker's TextBox, that would sure be simpler. Thanks.
0
Kaloyan
Telerik team
answered on 14 Jan 2011, 01:15 PM
Hello KO,

I am not sure weather I am understanding your case correctly. Initially you can use the DateTimeWatermarkTemplate property to set a TextBlock bounded to a property(bool for example) that will enable/disable the user input in case of invalid time typed. Follow the code bellow:

<telerik:RadTimePicker x:Name="radTimePicker" HorizontalAlignment="Center"
                VerticalAlignment="Center">
            <telerik:RadTimePicker.DateTimeWatermarkTemplate>
                <DataTemplate>
                    <Grid>
                        <TextBox Text="{Binding}" IsReadOnly="{Binding IsReadOnly}"
                                BorderBrush="{x:Null}" />
                    </Grid>
                </DataTemplate>
            </telerik:RadTimePicker.DateTimeWatermarkTemplate>
        </telerik:RadTimePicker>


Best wishes,
Kaloyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
TimePicker
Asked by
KO
Top achievements
Rank 1
Answers by
KO
Top achievements
Rank 1
Kaloyan
Telerik team
Share this question
or