protected override void OnElementDetaching( IFrameworkInputElement element) { var frameworkElement = element.As <FrameworkElement>(); HintAssist.SetInputDataAdapter(frameworkElement, null); frameworkElement.Loaded -= OnLoaded; element.GotKeyboardFocus -= OnGotKeyboardFocus; element.LostKeyboardFocus -= OnLostKeyboardFocus; element.PreviewTextInput -= OnPreviewTextInput; }
protected override void OnElementAttaching( IFrameworkInputElement element) { var frameworkElement = element.AsOrDefault <FrameworkElement>(); if (frameworkElement == null) { throw new NotSupportedException( $"Cannot host a {nameof(TextFieldInputVisualStateService).SQuote()} on the type " + $"{element.GetType().Name.SQuote()} because it must be assignable to the type " + $"{nameof(FrameworkElement).SQuote()}."); } HintAssist.SetInputDataAdapter(frameworkElement, new TextFieldInputDataAdapter(element)); frameworkElement.Loaded += OnLoaded; element.GotKeyboardFocus += OnGotKeyboardFocus; element.LostKeyboardFocus += OnLostKeyboardFocus; element.PreviewTextInput += OnPreviewTextInput; }