超链接按钮中的内容不显示 [英] Content in Hyperlink Button doesnt show

查看:52
本文介绍了超链接按钮中的内容不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Im currently trying to add some Style to my Hyperlinkbutton, but cannot get it to work.

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

After some searching, I found this Tutorial, but even after copying the whole code (and only changing the picture) it doesnt work for me. My SDK-Target is 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>

教程-网址:http://www.imaginativeuniversal.com/blog/post/2010/07/05/Navigating-around-windows-phone-7.aspx

推荐答案

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

The default control template for the HyperlinkButton is a TextBlock, so all it can handle is text!

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

One way to go around this is to change the control template, like this:

<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>

这篇关于超链接按钮中的内容不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆