//public static readonly DependencyProperty TextProperty = // DependencyProperty.Register( // "Text", // typeof(string), // typeof(TextBoxWithLabel), // new FrameworkPropertyMetadata("Label", // new PropertyChangedCallback(OnTextChanged), // new CoerceValueCallback(CoerceTextValue))); //public static readonly DependencyProperty LabelTextProperty = // DependencyProperty.Register( // "LabelText", // typeof(string), // typeof(TextBoxWithLabel), // new FrameworkPropertyMetadata("", // new PropertyChangedCallback(OnLabelTextChanged), // new CoerceValueCallback(CoerceLabelTextValue))); private static void OnTextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { TextBoxWithLabel control = (TextBoxWithLabel)obj; RoutedPropertyChangedEventArgs <string> e = new RoutedPropertyChangedEventArgs <string>( (string)args.OldValue, (string)args.NewValue, TextChangedEvent); control.OnTextChanged(e); }
private static void OnLabelTextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { TextBoxWithLabel control = obj as TextBoxWithLabel; if (control == null) { return; } RoutedPropertyChangedEventArgs <string> e = new RoutedPropertyChangedEventArgs <string>( (string)args.OldValue, (string)args.NewValue, LabelTextChangedEvent); control.OnLabelTextChanged(e); }