public FormattedString AsFormattedString(Color matchHighlightColor) { FormattedString formattedString = new FormattedString(); if (Index != 0) { formattedString.Spans.Add(new Span() { Text = EntryField.Substring(0, Index) }); } formattedString.Spans.Add(new Span() { Text = EntryField.Substring(Index, Length), ForegroundColor = matchHighlightColor }); int endIndex = Index + Length; if (endIndex != EntryField.Length) { formattedString.Spans.Add(new Span() { Text = EntryField.Substring(endIndex) }); } return(formattedString); }