我已经看到了一些建议,你可以通过Hyperlink控件添加到WPF应用程序的超链接.
这是我在我的代码中尝试使用它的方式:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="BookmarkWizV2.InfoPanels.Windows.UrlProperties"
Title="UrlProperties" Height="754" Width="576">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid>
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.RowSpan="2">
<StackPanel >
<DockPanel LastChildFill="True" Margin="0,5">
<TextBlock Text="Url:" Margin="5"
DockPanel.Dock="Left" VerticalAlignment="Center"/>
<TextBox Width="Auto">
<Hyperlink NavigateUri="http://www.google.co.in">
Click here
</Hyperlink>
</TextBox>
</DockPanel >
</StackPanel>
</ScrollViewer>
</Grid>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,7,2,7" Grid.Row="1" >
<Button Margin="0,0,10,0">
<TextBlock Text="Accept" Margin="15,3" />
</Button>
<Button Margin="0,0,10,0">
<TextBlock Text="Cancel" Margin="15,3" />
</Button>
</StackPanel>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
属性"文本"不支持"超链接"类型的值.
我究竟做错了什么?
问候,我在db中有一些文本,它如下:
Lorem ipsum dolor坐下来,精致的adipistur elit.Duis tellus nisl,venenatis et pharetra ac,tempor sed sapien.整齐的pellentesque blandit velit,在tempus urna semper坐下来.Duis mollis,libero ut consectetur interdum,massa tellus posuere nisi,eu aliquet elit lacus nec erat.赞美商品.**[a href =' http ://somesite.com']某个网站[/ a]**在新西兰的Suspendisse坐在amet massa molestie gravida feugiat ac sem.Phasellus ac mauris ipsum,vel auctor odio
我的问题是:我怎样才能显示Hyperlink一个TextBlock?我不想为此目的使用webBrowser控件.我不想使用此控件之一:http://www.codeproject.com/KB/WPF/htmltextblock.aspx也