Text winRT RichEditBox:在有限的字符范围内更改前景

Text winRT RichEditBox:在有限的字符范围内更改前景,text,microsoft-metro,format,winrt-xaml,Text,Microsoft Metro,Format,Winrt Xaml,我尝试了几种方法来更新我的RichEditBox的字符格式,但我一直无法更改它。以下是我迄今为止所做的尝试: 我有一个既定的目标: private RichEditBox _highlitedTextControlReference; 尝试: this._highlitedTextControlReference.Document.GetRange(0, 2).CharacterFormat.ForegroundColor = Colors.Orange; 另一次尝试: var format

我尝试了几种方法来更新我的RichEditBox的字符格式,但我一直无法更改它。以下是我迄今为止所做的尝试:

我有一个既定的目标:

private RichEditBox _highlitedTextControlReference;
尝试:

this._highlitedTextControlReference.Document.GetRange(0, 2).CharacterFormat.ForegroundColor = Colors.Orange;
另一次尝试:

var format = _highlitedTextControlReference.Document.GetDefaultCharacterFormat();
format.ForegroundColor = Colors.Orange;
_highlitedTextControlReference.Document.SetDefaultCharacterFormat(format);
_highlitedTextControlReference.Document.ApplyDisplayUpdates();
_highlitedTextControlReference.Document.Selection.TypeText("blah");
_highlitedTextControlReference.Document.Selection.CharacterFormat.ForegroundColor = Colors.Orange;
_highlitedTextControlReference.Document.Selection.TypeText("blah");
另一次尝试:

var format = _highlitedTextControlReference.Document.GetDefaultCharacterFormat();
format.ForegroundColor = Colors.Orange;
_highlitedTextControlReference.Document.SetDefaultCharacterFormat(format);
_highlitedTextControlReference.Document.ApplyDisplayUpdates();
_highlitedTextControlReference.Document.Selection.TypeText("blah");
_highlitedTextControlReference.Document.Selection.CharacterFormat.ForegroundColor = Colors.Orange;
_highlitedTextControlReference.Document.Selection.TypeText("blah");
我试图更改我发现的布尔值:

_highlitedTextControlReference.IsColorFontEnabled = true;
但所有这些都没有任何效果

我错过什么了吗


谢谢

您这样做是为了响应TextChanged事件吗?谢谢您的关注。并非所有情况下都如此。事实上,我在板凳上尝试了多个项目。就我所记得的,Loaded是我用得最多的一个。是否有一些事情与我错过的事件或生命周期有关?最近我试着这么做。我没有发现任何问题。Adnan,谢谢你的链接,我会用你的代码检查我的情况。我会通知你的!