/// <summary> /// Default constructor. /// </summary> public DateTimeTextBox() { var binding = new Binding(); binding.Source = this; binding.Path = new PropertyPath("SelectedValue"); binding.Mode = BindingMode.TwoWay; binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; _converter = new DateTimeConverter(); binding.Converter = _converter; binding.ValidationRules.Add(_converter); this.SetBinding(TextBox.TextProperty, binding); }