超链接按钮中的内容不显示

kad*_*dir 1 xaml windows-phone-7

我目前正在尝试将一些样式添加到我的超链接按钮,但无法使其工作.

经过一番搜索,我找到了这个教程,但即使在复制完整个代码(并且只更改图片)之后,它也不适用于我.我的SDK-Target是7.5.

在这里我的代码:

   <ScrollViewer>
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <HyperlinkButton NavigateUri="/Views/PanoramaPage.xaml" Content="Panorama" Foreground="{StaticResource PhoneAccentBrush}"/>
            <HyperlinkButton NavigateUri="/Views/PanoramaPage.xaml" Content="Pivot" Foreground="{StaticResource PhoneAccentBrush}"/>

            <HyperlinkButton Name="hyperlinkButton1" NavigateUri="/Views/PanoramaPage.xaml" >
                <Border BorderBrush="White" BorderThickness="5" Padding="10">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="60" Source="/Presentation;component/Images/refresh.png" />
                        <TextBlock VerticalAlignment="Center" Text="Go to View.xaml"/>
                    </StackPanel>
                </Border>
            </HyperlinkButton>

        </StackPanel>
    </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

Tutorial-Url:http: //www.imaginativeuniversal.com/blog/post/2010/07/05/Navigating-around-windows-phone-7.aspx

Ped*_*mas 7

HyperlinkBut​​ton的默认控件模板是TextBlock,所以它可以处理的只是文本!

解决此问题的一种方法是更改​​控件模板,如下所示:

<HyperlinkButton Name="hyperlinkButton1" NavigateUri="/Views/PanoramaPage.xaml">
    <HyperlinkButton.Template>
        <ControlTemplate TargetType="HyperlinkButton">
            <Border BorderBrush="White" BorderThickness="5" Padding="10">
                <StackPanel Orientation="Horizontal">
                    <Image Width="60" Source="/Presentation;component/Images/refresh.png" />
                    <TextBlock VerticalAlignment="Center" Text="Go to View.xaml"/>
                </StackPanel>
            </Border>
        </ControlTemplate>
    </HyperlinkButton.Template>
</HyperlinkButton>
Run Code Online (Sandbox Code Playgroud)