【问题标题】:Nullify the value binding on IntegerUpDown from spinner从微调器中取消 IntegerUpDown 上的值绑定
【发布时间】:2017-06-12 20:53:01
【问题描述】:

是否可以将IntegerUpDown(或任何UpDownBase)的Minimum 值设置为null

我希望控件的操作方式是:

  • 初始化为null
  • 如果用户增加微调器,则从 0 开始
  • 如果用户从0 递减,则返回null

我尝试了设置 IntegerUpDown.MinimumIntegerUpDown.DefaultValue 的各种组合,但属性绑定上的设置器似乎在无效后使用先前的值重新调用(如果有必要,可以更新解释)。

【问题讨论】:

    标签: c# wpf spinner wpftoolkit integerupdown


    【解决方案1】:

    您可以像这样定义可空整数(或其他默认不具有空选项的变量):

    int? IntegerUpDown = null;
    if (IntegerUpDown.HasValue)
    {
        int NewInt = IntegerUpDown.Value;
    }
    

    【讨论】:

    • 我猜@reasra 说的是WpfToolkit 控件...
    • 嗯,这是将变量设置为可为空的基础知识,其余的应该由他/她完成:D
    • 感谢您的回答。我将值绑定到int?。我只是希望用户界面使用IntegerUpDown 的微调器将值设置为null
    猜你喜欢
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多