Example #1
0
        /// <summary>
        /// Called when the XAML text property is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnXamlTextPropertyChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended textBox = (RichTextBoxExtended)dependencyObject;
            string value = (string)e.NewValue;

            if (string.IsNullOrWhiteSpace(value))
            {
                textBox.isXamlTextChanging = true;
                textBox.SetText(string.Empty);
                textBox.isXamlTextChanging = false;

                textBox.ClearUndo();
            }
            else
            {
                if (textBox.isXamlTextChanging)
                {
                    return;
                }

                textBox.isXamlTextChanging = true;
                textBox.SetXaml(value);
                textBox.isXamlTextChanging = false;

                textBox.ClearUndo();
            }
        }
Example #2
0
        /// <summary>
        /// Called when the text property is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnTextPropertyChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended textBox = (RichTextBoxExtended)dependencyObject;
            string value = (string)e.NewValue;

            if (textBox.isTextChanging)
            {
                return;
            }

            textBox.isTextChanging = true;
            textBox.SetText(value);
            textBox.isTextChanging = false;

            textBox.ClearUndo();
        }