public TextBoxExceptionValidationRule()
        {
            InitializeComponent();

            Customer customer1 = new Customer() { Name = "lili" };
            textBox2.DataContext = customer1;
        }
        public TextBoxSubValidationRule()
        {
            InitializeComponent();

            //            <Binding Path="">
            //    <Binding.ValidationRules>
            //        <validators:StringRangeValidationRule
            //MinimumLength="1"
            //ErrorMessage="" />
            //    </Binding.ValidationRules>
            //</Binding>

            Customer customer1 = new Customer() { Name = "lili" };
            textBox1.DataContext = customer1;

            Binding b = new Binding();
            b.Path = new PropertyPath("Name");
            b.ValidationRules.Add(new StringRangeValidationRule() { ErrorMessage = "A name is required.", MinimumLength = 1 });
            textBox1.SetBinding(TextBox.TextProperty, b);
        }