Пример #1
0
        public static TextFieldInputVisualStateService GetTextFieldInputVisualStateService(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetTextFieldInputVisualStateService(@this));
        }
Пример #2
0
        public static IStringValidator GetValidator(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetValidator(@this));
        }
Пример #3
0
        public static bool GetIsRequiredField(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetIsRequiredField(@this));
        }
Пример #4
0
        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;
        }
Пример #5
0
        public static TextFieldInputDataAdapter GetInputDataAdapter(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            var inputDataAdapter = HintAssist.GetInputDataAdapter(@this);

            if (inputDataAdapter == null)
            {
                throw new InvalidOperationException(
                          $"The \'HintAssist.InputDataAdapter\' attached property has not been set.");
            }

            return(inputDataAdapter);
        }
Пример #6
0
        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;
        }