阅读背景:

如何在WPF TextBox上显示无效Dependency属性的红色边框?

来源:互联网 

I have this code

我有这个代码

using System.Windows;

namespace TestWpfApplication
{
    public partial class Window5 : Window
    {
        public Window5()
        {
            InitializeComponent();
        }
        public int XX
        {
            get { return (int)GetValue(XXProperty); }
            set { SetValue(XXProperty, value); }
        }

        public static readonly DependencyProperty XXProperty =
            DependencyProperty.Register("XX", typeof(int), typeof(Window5), new PropertyMetadata(1),ValidateXX);

        private static bool ValidateXX(object value)
        {
            int? d =value as int?;
            var res= d != null && d > 0 && d < 20;
            return res;
        }
    }
}
using System.Windo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: