问题描述
我有一个绑定到Double类型变量的TextBox。
< TextBox Text = {Binding Path = OldRegCost,Mode = TwoWay,UpdateSourceTrigger = PropertyChanged} Grid.Row = 0 Grid.Column = 1高度= 25宽度= 50 Margin = 10,0,10,0 > < / TextBox >
In后面的代码我将文本框绑定到Double类型变量。
private 双跨度>? _OldRegCost;
public Double ? OldRegCost
{
get { return _OldRegCost; }
set
{
OldRegCost = value ;
RaisePropertyChanged( OldRegCost);
}
}
当用户尝试输入符号时(@,#,$,%, & etc)TextBox自动变成红色。
它还修剪输入的特殊字符。
因为我正在使用单独的验证代码背后的正则表达式:
1)在代码中是否有任何方法可以知道文本字段是否变为RED(输入的字符无效)
2)或者我可以删除RED效果并获取整个文本(带有无效字符)后面的代码。
请给我一个解决方案
I have a TextBox Bound to a Double type variable.
<TextBox Text="{Binding Path=OldRegCost,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1" Height="25" Width="50" Margin="10,0,10,0"></TextBox>
In the code behind i binded the textbox to a Double type variable.
private Double? _OldRegCost; public Double? OldRegCost { get { return _OldRegCost; } set { OldRegCost = value; RaisePropertyChanged("OldRegCost"); } }
When the user try to enter a symbol (@,#,$,%,& etc) the TextBox automatically turns RED colour.
It also trims the entered special character.
Since am doing a separate validation using Regex in code behind:
1) Is there any way in code behind to know whether the text field turned RED (an invalid character entered)
2) or can i remove the RED effect and get the entire text (with invalid character) to code behind.
Please give me a solution
这篇关于我的文本框内容被修剪。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!