【发布时间】:2017-10-23 09:02:18
【问题描述】:
我有一个由按钮和文本框组成的控件。
我想设置文本框的输入范围,所以我引入了一个新的依赖属性:
public InputScope InputScope
{
get { return (InputScope)GetValue(InputScopeProperty); }
set { SetValue(InputScopeProperty, value); } // Notify prop change
}
public static readonly DependencyProperty InputScopeProperty =
DependencyProperty.Register(nameof(InputScope), typeof(InputScope), typeof(SearchControl), new PropertyMetadata(DependencyProperty.UnsetValue));
在 XAML 中:
<controls:SearchControl InputScope="Number" /> <!-- etc... -->
(显然将其分配给此自定义控件样式的文本框的 InputScope 属性。)
我的问题:虽然这可行,但数字键盘在获得焦点时会显示,但我在 XAML 中有蓝色下划线,并且还有一条错误消息:“InputScope”的 TypeConverter 不支持转换来自一个字符串。
有没有办法在没有肮脏黑客的情况下修复它?
【问题讨论】:
标签: xaml uwp dependency-properties inputscope