【问题标题】:How to set the maximum count of chars in a telerik TextBox如何在 Telerik TextBox 中设置最大字符数
【发布时间】:2015-08-20 03:08:39
【问题描述】:
<telerik:RadAutoCompleteBox 
    Style="{StaticResource someStyle}" 
    WatermarkContent="{ext:LocalizedText Key=someKey}" 
    SearchText="{Binding SearchTextBox, Mode=TwoWay}"
    TextSearchMode="Contains" IsTabStop="False" Height="34">

    <telerik:RadAutoCompleteBox.InputBindings>
        <KeyBinding Key="Enter" Command="{Binding someCommand}"/>
    </telerik:RadAutoCompleteBox.InputBindings>
</telerik:RadAutoCompleteBox>

我尝试了MaxLength,但显然不支持此类属性。

【问题讨论】:

  • 你的意思是文本框中“允许的最大字符数”吗?
  • 是的,textbox 标签的“maxLength”

标签: c# wpf xaml telerik


【解决方案1】:

Doesn't look like there's any max length properties for that specific control by default.

但是,您应该能够轻松地操作您与Command 属性绑定的方法,以首先检查文本框并确保它不超过一定数量的字符。

如果是,则停止执行命令。如果没有,请继续。

【讨论】:

  • 但是您的建议将允许用户输入超过允许数量的字符吗?
  • 如果他们这样做,则停止执行并显示错误消息。也许我误会了?您想在输入达到一定数量的字符后完全停止输入吗?
  • 是的,如果我将它设置为 5 个字符,用户将无法输入第 6 个字符
  • Change() 事件监听器呢?你能绑定一个验证器吗?
  • 你介意给我看一小段代码,因为我是 wpf 领域的新手
猜你喜欢
  • 2023-03-24
  • 2011-08-29
  • 2014-01-02
  • 1970-01-01
  • 2012-09-16
  • 2014-10-31
  • 1970-01-01
相关资源
最近更新 更多