-1
WPFにRichTextBox(Name="txtGoTo"
)があり、最初の文字は赤で塗りつぶすだけです(残りの部分は黒です)。RichTextBox:最初の文字の色が異なります。
これは私が試した(オンラインそれを得た)ものですが、それは動作しません:
Dim rtb As RichTextBox = txtGoTo
Dim Text As String = New TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd).Text
If Not String.IsNullOrEmpty(Text) Then
Dim RangeAisle As TextPointer = rtb.Document.ContentStart
Dim RangeShelf As TextPointer = rtb.Document.ContentStart.GetPositionAtOffset(1)
Dim tr As New TextRange(RangeAisle, RangeShelf)
tr.ApplyPropertyValue(RichTextBox.ForegroundProperty, Brushes.Red)
End If
Visual Studioは、私に新しいTextRangeの 'の新しい下の構文エラー(起動、[終了])。ApplyPropertyValue(TextElement.ForegroundProperty、Brushes.Redを)'与えます –