2011-06-20 31 views
2

テキストとハイパーリンクを含むWPF richtextboxがあります。私はボタンを押すと、選択したハイパーリンクのフォントサイズを変更したい。私が持っている問題は、私はrichtextboxの選択から選択されたハイパーリンクを得ることができないということです。RichTextBoxハイパーリンク

よろしく

マリアン

PS。ここにデモをアップロードしました:http://cid-6d5e36974c8e12a8.office.live.com/self.aspx/RTB%20Hyperlink/RTBDemo.zip

PS2キャレット位置のrtbへのハイパーリンクの追加:

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。設定フォント:

TextRange text = new TextRange(rtb.Selection.Start, rtb.Selection.End); 
text.ApplyPropertyValue(TextElement.FontSizeProperty, 14.00); 

は解決:http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/23fcf1b7-8708-40ca-b3b0-658a96a795eb/#b2f32824-fab6-45cc-8c81-7c26986b12bf

+2

が代わりにダウンロードする必要があり、コードをデモへのリンク、あなたの質問では、関連するコードを貼り付けて、あなたが買ってあげるチャンスを改善します良い答え。 –

答えて

関連する問題