/// <summary> /// TextProperty property changed handler. /// </summary> /// <param name="d">DatePicker that changed its Text.</param> /// <param name="e">DependencyPropertyChangedEventArgs.</param> private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DatePicker dp = d as DatePicker; Debug.Assert(dp != null); if (!dp.IsHandlerSuspended(DatePicker.TextProperty)) { string newValue = e.NewValue as string; if (newValue != null) { if (dp._textBox != null) { dp._textBox.Text = newValue; } else { dp._defaultText = newValue; } dp.SetSelectedDate(); } else { dp.SetValueNoCallback(DatePicker.SelectedDateProperty, null); } } }
/// <summary> /// TextProperty property changed handler. /// </summary> /// <param name="d">DatePicker that changed its Text.</param> /// <param name="e">DependencyPropertyChangedEventArgs.</param> private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DatePicker dp = d as DatePicker; Debug.Assert(dp != null); if (!dp.IsHandlerSuspended(DatePicker.TextProperty)) { string newValue = e.NewValue as string; if (newValue != null) { if (dp._textBox != null) { dp._textBox.Text = newValue; } else { dp._defaultText = newValue; } dp.SetSelectedDate(); } else { dp.SetValueNoCallback(DatePicker.SelectedDateProperty, null); } } DatePickerAutomationPeer peer = UIElementAutomationPeer.FromElement(dp) as DatePickerAutomationPeer; // Raise the propetyChangeEvent for Value if Automation Peer exist if (peer != null) { peer.RaiseValuePropertyChangedEvent((string)e.OldValue, (string)e.NewValue); } }