We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用数值选择框控件时,当触发VerifyFunc校验,且校验结果为Failed时,后台再次给控件的value赋值,前台控件输入框不更新。
<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" xmlns:hc="https://handyorg.github.io/handycontrol" Title="MainWindow" Height="450" Width="800"> <StackPanel> <hc:NumericUpDown x:Name="nud" Style="{StaticResource NumericUpDownPlus}"/> <Button Content="Test" Click="Button_Click"/> </StackPanel> </Window>
using HandyControl.Data; using System.Windows; namespace WpfApp1 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); nud.VerifyFunc = value => { if (double.TryParse(value,out double d) && d < 10) return OperationResult.Failed("测试测试"); return OperationResult.Success(); }; } private void Button_Click(object sender, RoutedEventArgs e) { nud.Value = 10; } } }
查源码后发现,校验结果为Failed后,value仍为上一次的合法值10。输入非法值不会更新value属性。所以第二次点击按钮不会触发Value属性的PropertyChanged。
在CorceValueCallBack中设置Text,原因是当使用绑定时,属性的Set访问器不会被调用,PropertyChanged不一定触发(当值相同时),目前只想到在CorceValue里更新,如有更好的解决方法,还请告知,谢谢。见 PullRequest #395
The text was updated successfully, but these errors were encountered:
fix bug HandyOrg#393
f4d9494
c9920ba
Successfully merging a pull request may close this issue.
NumericUpDown在VerifyFunc校验不通过的情况下无法正常更新显示的值
现象
使用数值选择框控件时,当触发VerifyFunc校验,且校验结果为Failed时,后台再次给控件的value赋值,前台控件输入框不更新。
重现问题
XAML
XAML.CS
操作步骤
原因
查源码后发现,校验结果为Failed后,value仍为上一次的合法值10。输入非法值不会更新value属性。所以第二次点击按钮不会触发Value属性的PropertyChanged。
修改方法
在CorceValueCallBack中设置Text,原因是当使用绑定时,属性的Set访问器不会被调用,PropertyChanged不一定触发(当值相同时),目前只想到在CorceValue里更新,如有更好的解决方法,还请告知,谢谢。见 PullRequest #395
The text was updated successfully, but these errors were encountered: