以编程方式在文本之间创建带有超链接的文本块

在XAML中,我有以下代码:

 

现在我想摆脱整个TextBlock XAML并以编程方式添加该位。 我创建TextBlock没有问题,将Text属性设置为’click please’并向TextBlock.Content添加超链接。 但是如何在“点击”和“请”之间定位超链接? 如何将超链接的文本设置为“here”?

我没有太大的进展,到目前为止,我得到的是:

  label2.Content = new TextBlock() { Text = "click please" }; //(label2.Content as TextBlock).Content does not exist? //and even if it does.. how do I squeeze the hyperlink in between the text? 

这是在中间添加带有可点击链接的TextBlock的代码:

 Run run1 = new Run("click "); Run run2 = new Run(" Please"); Run run3 = new Run("here."); Hyperlink hyperlink = new Hyperlink(run3) { NavigateUri = new Uri("http://stackoverflow.com") }; hyperlink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(hyperlink_RequestNavigate); //to be implemented textBlock1.Inlines.Clear(); textBlock1.Inlines.Add(run1); textBlock1.Inlines.Add(hyperlink); textBlock1.Inlines.Add(run2);