在XAML中,我有以下代碼:編程使超鏈接文本塊中的文本之間
<Label Width="120" Height="20" Name="label1" SnapsToDevicePixels="True" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left">
click
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="foo">here</Hyperlink>
please
</TextBlock>
</Label>
現在,我想擺脫整個TextBlock的XAML,並添加該位編程。我沒有創建TextBlock的麻煩,將Text屬性設置爲'請點擊'並添加一個超鏈接到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?
你有沒有你已經嘗試過的代碼? –
我加了我所擁有的,但並沒有太多... – mtijn