/// <summary> /// Callback for changes to the any behavioral property. /// Transfers the new value to a FlowDocument. /// </summary> /// <remarks> /// Behavioral properties must be transferred to any document whether it has Standalone /// or Inherited FormattingDefaults. All such values are set as local values even /// in case when they are equal to the ones inherited from the UI context. /// Such strong logic is needed to work correctly in any sequence of /// setting FormattingDefaults property and adding children. /// </remarks> private static void OnBehavioralPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RichTextBox richTextBox = (RichTextBox)d; richTextBox.TransferBehavioralProperty(e.Property, e.NewValue); }