本文介绍了WP - 如何以编程方式删除超链接按钮中的下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 C# 开发了一个超链接按钮.hyperlinkBut​​ton 中的下划线让我很恼火.我不知道如何删除它.帮我删除下划线,我需要用 C# 回答.[这是一个 WP8 应用程序]

I have developed an hyperlinkButton in C#. The underline in hyperlinkButton irritates me. I don't know how to remove it. Help me to remove the underline and i need answer in C#. [It's an WP8 app]

    HyperlinkButton hyperlinkButton = new HyperlinkButton()
    {
        Content = "Click me",
        HorizontalAlignment = HorizontalAlignment.Left,
        NavigateUri = new Uri("http://my-link-com", UriKind.Absolute)
    };

推荐答案

除了在 XAML 中设置 ControlTemplate 之外,我不知道其他方法.但是你可以在 C# 中使用它:

I don't know another way but setting the ControlTemplate in XAML. But you can use it in C#:

var str =   "<ControlTemplate TargetType=\"HyperlinkButton\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">" +
            "   <TextBlock HorizontalAlignment=\"{TemplateBinding HorizontalContentAlignment}\" Text=\"{TemplateBinding Content}\" VerticalAlignment=\"{TemplateBinding VerticalContentAlignment}\"/>" +
            "</ControlTemplate>";

var template = (ControlTemplate)XamlReader.Load(str);

HyperlinkButton hyperlinkButton = new HyperlinkButton()
{
    Content = "Click me",
    HorizontalAlignment = HorizontalAlignment.Left,
    NavigateUri = new Uri("http://my-link-com", UriKind.Absolute),
    Template = template
};

希望能帮到你

这篇关于WP - 如何以编程方式删除超链接按钮中的下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:55