RichTextBox Hyperlink
I have a WPF richtextbox that contains text and hyperlinks. I want to change the font size for the selected hyperlink when i press a button. The problem that i have is that i am not able to get the selected hyperlink from the richtextbox selection.
Best Regards
Marian
PS. I've uploaded a demo here: http://cid-6d5e36974c8e12a8.office.live.com/self.aspx/RTB%20Hyperlink/RTBDemo.zip
PS2. Adding hyperlink to rtb at caret position:
Run hyper = new Run("SampleLink");
Hyperlink hp = new Hyperlink(hyper);
hp.Click += new RoutedEventHandler(hp_Click);
TextBlock tb = new TextBlock();
tb.FontSize = 10;
tb.Inlines.Add(hp);
using (rtb.DeclareChangeBlock())
{
TextPointer tp = rtb.CaretPosition.GetPositionAtOffset(0, LogicalDirection.Forward);
InlineUIContainer inlineUIContainer = new InlineUIContainer(tb, tp);
rtb.CaretPosition = inlineUIContainer.ElementEnd;
}
rtb.IsDocumentEnabled = true;
PS3. Setting font:
TextRange text = new TextRange(rtb.Selection.Start, rtb.Selection.End);
text.ApplyPropertyV开发者_高级运维alue(TextElement.FontSizeProperty, 14.00);
Solved: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/23fcf1b7-8708-40ca-b3b0-658a96a795eb/#b2f32824-fab6-45cc-8c81-7c26986b12bf
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/23fcf1b7-8708-40ca-b3b0-658a96a795eb/#b2f32824-fab6-45cc-8c81-7c26986b12bf
精彩评论