Reputation: 303
I'm using Extended WPF Toolkit and I need to disable keyboard input for TextBox (or whatever it is) in DateTimePicker. I've already tried this:
<xctk:DateTimePicker Value="{Binding DateStart, Mode=TwoWay}" Style="{StaticResource CustomDatePicker}">
<xctk:DateTimePicker.Resources>
<Style TargetType="TextBox">
<Setter Property="IsReadOnly" Value="True"/>
</Style>
</xctk:DateTimePicker.Resources>
</xctk:DateTimePicker>
For both TargetType="TextBox"
and TargetType="DatePickerTextBox"
- they don't work.
How can I disable keyboard input (without making it ReadOnly
- I still need to be able to pick date and time)?
Upvotes: 2
Views: 4077
Reputation: 989
<textarea rows=3 cols=20></textarea>
$("textarea").keydown(false);
=========2nd option=======
<input type='text' id='foo' readonly='true'>
=======3rd option===============
$('#rush_needed_by_english').keydown(function() {
return false;
});
Upvotes: 0
Reputation: 8363
Not sure if Rahul's answer works or not, because I have slightly different answer.
<Style TargetType="{x:Type xctk:WatermarkTextBox}">
<Setter Property="IsReadOnly" Value="True"/>
</Style>
Upvotes: 0
Reputation: 6337
Your TargetType
is wrong. You need to change your TargetType
like below:
TargetType="{xctk:Type toolkitPrimitives:DatePickerTextBox}"
Note : Make sure you are having reference to the toolkitPrimitives namespace
e.g xmlns:toolkitPrimitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit
Upvotes: 1
Reputation: 1660
You can try to use AllowTextInput
property.
<xctk:DateTimePicker Height="20" Width="200" AllowTextInput="False" />
Upvotes: 2