Remove underline in Windows Phone hyperlinkbutton

Source: Internet
Author: User

When using hyperlinkbutton today, I used a problem that I wanted to remove the underline, but I couldn't find it for a long time. It contained the underline attribute.

So I found a method to modify the template with blend on the Internet, but I personally think it is troublesome and will generate a lot of code.

 

Therefore, when you see the controltemeplate knowledge, you can use your custom template to solve the problem.

My idea is, set the content attribute of hyperlinkbutton to null, and then add a textblock to controltemeplate to display text without a strip.

View code

<Hyperlinkbutton Height = "30" horizontalalignment = "Left" margin = "200, 90," name = "hyperlinkbutton2" verticalignment = "TOP" width = "" navigateuri = "/mainpage. XAML "> 

 

But later I see the book saying that this setting is not good, because the content attribute of hyperlinkbutton is the object attribute, so we can set values of the image, panel, and other types.

The method provided in the book is to use the content attribute of contentpresenter to set it because it is also the object type. In addition, it can bind the content attribute value of hyperlinkbutton itself and it does not have a slide line.

View code

 <HyperlinkButton Content="NAVIGATION">                <HyperlinkButton.Style>                    <Style TargetType="HyperlinkButton">                        <Setter Property="Template">                            <Setter.Value>                                <ControlTemplate TargetType="HyperlinkButton">                                    <Border>                                    <ContentPresenter Content="{TemplateBinding Content}"/>                                    </Border>                                </ControlTemplate>                            </Setter.Value>                        </Setter>                    </Style>                </HyperlinkButton.Style>            </HyperlinkButton>

Note that you must set the value of the targettype attribute when setting the controltemplate. Otherwise, an unhandled exception will be reported. This is the reason why I debugged the targettype for one afternoon and found that the error could not be solved .....

If you know why targettype must be set, thank you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.