c# - 禁用 IntegerUpDown 控件的文本输入 - WPF
问题描述
我有一个来自 WPF 扩展库 (Xceed) 的 IntegerUpDown 控件。我希望用户只使用向上/向下箭头输入一个值,而不能在其中输入一个值
我曾尝试使用 IsReadOnly 属性,但这也禁用了向上/向下箭头。
<xctk:IntegerUpDown IsReadOnly="True" DisplayDefaultValueOnEmptyText="True" GotFocus="Day_GotFocus" LostFocus="Day_LostFocus" x:Name="Day" Value="{Binding DayText, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Style="{StaticResource BaseDateInputTextBoxesStyle}" Minimum="{Binding MinimumDateSelection}" Maximum="{Binding MaximumDateSelection}">
<xctk:IntegerUpDown.Watermark>
<TextBlock Text="Day" Foreground="{StaticResource OffsetWhiteBrush}" Margin="0,0,60,0"/>
</xctk:IntegerUpDown.Watermark>
</xctk:IntegerUpDown>
如何禁用文本框区域,以便用户无法键入值而只能使用向上/向下箭头键?
解决方案
IntegerUpDown 有一个属性可以满足您的要求:AllowTextInput="False"
推荐阅读
- javascript - 给泡泡添加点 - JS
- javascript - 为什么我在我的 Vigenere 密码算法的解密输出中得到随机的未定义字符?
- regex - 如何将文本从字符串末尾移动到开头
- javascript - 如何通过单击可编辑的 div 然后使用 Jquery 按下键盘上的 Delete 键来删除它?
- javascript - 在 javascript 中将 EventListener 定义为 ul 列表项的问题
- python - 无法在 mac 上安装支持 python3 的 postgres
- c++ - 'g++' 不是内部或外部命令、可运行程序或批处理文件。
- gps - 如何将 gps 模块的实时位置检索到我的数据库中,以便可以在多个应用程序中使用它?
- prolog - 如何获得所有重复列表元素的组合 - 序言
- php - Laravel belongsTo 和 hasMany 不返回数据