标签:ati http dex slide image demo bind string max
要求:年龄不满18 就边框飘红
后台代码:
public class AgeInfoWithValidation : IDataErrorInfo { public int Age { get; set; } public string this[string columnName] { get { if (columnName == "Age") return Age < 18 ? $"年龄:{Age},未成年" : null; return null; } } public string Error => throw new NotImplementedException(); }
前台代码:
<StackPanel> <StackPanel.DataContext> <local:AgeInfoWithValidation/> </StackPanel.DataContext> <Slider x:Name="age" Minimum="0" Maximum="100" Value="{Binding Age, UpdateSourceTrigger=PropertyChanged}" /> <Label > <Label.Content> <Binding Path="Age"> <Binding.ValidationRules> <DataErrorValidationRule/> </Binding.ValidationRules> </Binding> </Label.Content> </Label> </StackPanel>
效果:
标签:ati http dex slide image demo bind string max
原文地址:https://www.cnblogs.com/bug01/p/14388558.html