开发者

Getting text color from Silverlight RichTextBox

开发者 https://www.devze.com 2023-03-18 18:47 出处:网络
I have a problem with the getting 开发者_开发知识库the RichTextBox`s text color. There is a method about it but i was fail with it. help me to use this method or is there any way to do this.

I have a problem with the getting 开发者_开发知识库the RichTextBox`s text color. There is a method about it but i was fail with it. help me to use this method or is there any way to do this. Here is the method

run.Foreground(DependencyProperty)


I'm not sure what that method is supposed to do, but in XAML you would use:

<RichTextBox Name="MyBox" Text="Some text" Foreground="Red" />

or you could bind it to a Brush property:

<RichTextBox Name="MyBox" Text="Some text" Foreground="{Binding myColor}" />

If you're trying to set it from code behind:

Brush myBrush = new SolidColorBrush(Color.Red);
MyBox.Foreground = myBrush;


I just find the answer of my question

((System.Windows.Media.SolidColorBrush)(run.Foreground)).Color.ToString()

with above code i can get the color of the text in hex.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号