Esempio n. 1
0
        public static TextFieldInputVisualStateService GetTextFieldInputVisualStateService(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetTextFieldInputVisualStateService(@this));
        }
Esempio n. 2
0
        public static IStringValidator GetValidator(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetValidator(@this));
        }
Esempio n. 3
0
        public static bool GetIsRequiredField(
            [NotNull] this FrameworkElement @this)
        {
            @this.IsNotNull(nameof(@this));

            return(HintAssist.GetIsRequiredField(@this));
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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;
        }