private static void ApplyStructuralInlinePropertyAcrossRun(TextPointer start, TextPointer end, Run run, DependencyProperty formattingProperty, object value) { if (start.CompareTo(end) == 0) { // When the range is empty we should ignore the command, except // for the case of empty Run which can be encountered in empty paragraphs if (run.IsEmpty) { run.SetValue(formattingProperty, value); } } else { // Split elements at start and end boundaries. start = SplitFormattingElements(start, /*keepEmptyFormatting:*/false, /*limitingAncestor*/run.Parent as TextElement); end = SplitFormattingElements(end, /*keepEmptyFormatting:*/false, /*limitingAncestor*/run.Parent as TextElement); run = (Run)start.GetAdjacentElement(LogicalDirection.Forward); run.SetValue(formattingProperty, value); } // Clear property value from all ancestors of this Run. FixupStructuralPropertyEnvironment(run, formattingProperty); }