通过自己自定义模板可以解决
思路是把HyperlinkButton的Content属性设置为空 再定义ControlTemeplate在里面加一个TextBlock用于显示没有下滑线的文本
<HyperlinkButton Height="30" HorizontalAlignment="Left" Margin="100,90,0,0" Name="hyperlinkButton2" VerticalAlignment="Top" Width="200" NavigateUri="/MainPage.xaml"><HyperlinkButton.Template><ControlTemplate><!-- 下面是使用添加一个文本控件方法实现把下滑线去掉--><TextBlock TextAlignment="Center">导航</TextBlock></ControlTemplate></HyperlinkButton.Template></HyperlinkButton>
但是后面我有看到书上说这样子设置不好,因为HyperlinkButton的Content属性是object属性 所以我们就可以设置image、Panel等类型的值。
书上提供的方法是使用ContentPresenter的Content属性来设置 因为他也是Object的类型。并且通过它还可以绑定HyperlinkButton本身的Content属性值并且没有下滑线