Пример #1
0
        static TextBlock()
        {
            TextProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata(
                                              (string)Controls.TextBlock.TextProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue,
                                              (o, e) => (o as TextBlock)?.OnTextChanged(e.NewValue as string)));

            ForegroundProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata(
                                                    (Brush)ForegroundProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue,
                                                    (o, e) => (o as TextBlock)?.OnForegroundChanged(e.NewValue as Brush)));

            FontSizeProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata(
                                                  (double)FontSizeProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue,
                                                  (o, e) => (o as TextBlock)?.OnFontSizeChanged((double)e.NewValue)));

            TextWrappingProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata(
                                                      (TextWrapping)TextWrappingProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue,
                                                      (o, e) => (o as TextBlock)?.OnTextWrappingChanged((TextWrapping)e.NewValue)));
        }
Пример #2
0
        private void InitializeProperties()
        {
            UpdatePlaceholderVisibility();
            UpdateButtonStates();
            OnInputScopeChanged(CreateInitialValueChangerEventArgs(InputScopeProperty, null, InputScope));
            OnMaxLengthChanged(CreateInitialValueChangerEventArgs(MaxLengthProperty, null, MaxLength));
            OnAcceptsReturnChanged(CreateInitialValueChangerEventArgs(AcceptsReturnProperty, null, AcceptsReturn));
            OnIsReadonlyChanged(CreateInitialValueChangerEventArgs(IsReadOnlyProperty, null, IsReadOnly));
            OnForegroundColorChanged(null, Foreground);
            UpdateFontPartial();
            OnHeaderChanged();
            OnIsTextPredictionEnabledChanged(CreateInitialValueChangerEventArgs(IsTextPredictionEnabledProperty, IsTextPredictionEnabledProperty.GetMetadata(GetType()).DefaultValue, IsTextPredictionEnabled));
            OnIsSpellCheckEnabledChanged(CreateInitialValueChangerEventArgs(IsSpellCheckEnabledProperty, IsSpellCheckEnabledProperty.GetMetadata(GetType()).DefaultValue, IsSpellCheckEnabled));
            OnTextAlignmentChanged(CreateInitialValueChangerEventArgs(TextAlignmentProperty, TextAlignmentProperty.GetMetadata(GetType()).DefaultValue, TextAlignment));
            OnTextWrappingChanged(CreateInitialValueChangerEventArgs(TextWrappingProperty, TextWrappingProperty.GetMetadata(GetType()).DefaultValue, TextWrapping));
            OnFocusStateChanged((FocusState)FocusStateProperty.GetMetadata(GetType()).DefaultValue, FocusState, initial: true);
            OnVerticalContentAlignmentChanged(VerticalAlignment.Top, VerticalContentAlignment);
            OnTextCharacterCasingChanged(CreateInitialValueChangerEventArgs(CharacterCasingProperty, CharacterCasingProperty.GetMetadata(GetType()).DefaultValue, CharacterCasing));

            var buttonRef = _deleteButton?.GetTarget();

            if (buttonRef != null)
            {
                var thisRef = (this as IWeakReferenceProvider).WeakReference;
                buttonRef.Command = new DelegateCommand(() => (thisRef.Target as TextBox)?.DeleteButtonClick());
            }

            InitializePropertiesPartial();
        }
Пример #3
0
        private void InitializeProperties()
        {
            OnTextChanged(CreateInitialValueChangerEventArgs(TextProperty, null, Text));
            OnInputScopeChanged(CreateInitialValueChangerEventArgs(InputScopeProperty, null, InputScope));
            OnMaxLengthChanged(CreateInitialValueChangerEventArgs(MaxLengthProperty, null, MaxLength));
            OnAcceptsReturnChanged(CreateInitialValueChangerEventArgs(AcceptsReturnProperty, null, AcceptsReturn));
            OnIsEnabledChanged(false, IsEnabled);
            OnForegroundColorChanged(null, Foreground);
            UpdateFontPartial(this);
            OnHeaderChanged();
            OnIsTextPredictionEnabledChanged(CreateInitialValueChangerEventArgs(IsTextPredictionEnabledProperty, IsTextPredictionEnabledProperty.GetMetadata(GetType()).DefaultValue, IsTextPredictionEnabled));
            OnIsSpellCheckEnabledChanged(CreateInitialValueChangerEventArgs(IsSpellCheckEnabledProperty, IsSpellCheckEnabledProperty.GetMetadata(GetType()).DefaultValue, IsSpellCheckEnabled));
            OnTextAlignmentChanged(CreateInitialValueChangerEventArgs(TextAlignmentProperty, TextAlignmentProperty.GetMetadata(GetType()).DefaultValue, TextAlignment));
            OnTextWrappingChanged(CreateInitialValueChangerEventArgs(TextWrappingProperty, TextWrappingProperty.GetMetadata(GetType()).DefaultValue, TextWrapping));
            OnFocusStateChanged((FocusState)FocusStateProperty.GetMetadata(GetType()).DefaultValue, FocusState);

            var buttonRef = _deleteButton?.GetTarget();

            if (buttonRef != null)
            {
                buttonRef.Command = new DelegateCommand(DeleteText);
            }

            InitializePropertiesPartial();
        }
Пример #4
0
 set => SetValue(TextWrappingProperty, value);