2012-09-18 54 views
1

我在Windows 8中使用新的RichEditBox,并尝试选择文本范围并更改文本颜色。下面的代码将下划线并更改所选文本的背景,但ForegroundColor不会更改,文本只是保持黑色。在RichEditBox中更改文本颜色

result.Document.SetText(Windows.UI.Text.TextSetOptions.None, "Hello World");    
var range = result.Document.GetRange(0, 5); 

range.CharacterFormat.Underline = Windows.UI.Text.UnderlineType.DoubleWave; 
range.CharacterFormat.ForegroundColor = Windows.UI.Color.FromArgb(255, 0, 0, 255); 
range.CharacterFormat.BackgroundColor = Windows.UI.Color.FromArgb(255, 0, 255, 0); 

如何更改为RichEditBox内的ITextRange的文本颜色?

回答

2

您需要拨打Document.ApplyDisplayUpdates才能看到对文本的更改。

result.Document.ApplyDisplayUpdates();