【问题标题】:Windows 8 app adding click event to HyperLinkButton doesnot workWindows 8 应用程序将点击事件添加到超链接按钮不起作用
【发布时间】:2014-10-01 15:00:15
【问题描述】:

我有一些超链接按钮,我以编程方式为其添加了点击侦听器。但是在事件处理程序中编写的代码不会被调用。我错过了什么吗?下面是代码

    private void createTextBlocksForEachLavel(List<Folder> parents)
    {
        foreach(Folder parent in parents){
            addHyperLinkButton(parent.Name);
        }
    }

    private void addHyperLinkButton(String name)
    {
        HyperlinkButton button = new HyperlinkButton();
        button.IsHitTestVisible = false;
        button.VerticalAlignment = VerticalAlignment.Bottom;
        button.Foreground = new SolidColorBrush(Colors.Black);
        button.FontFamily = new FontFamily("Segoe UI Light");
        button.FontSize = 20;
        button.Content = name;
        if (!name.Equals(">"))
        {
            button.Click += button_Click;
        }
        hierarchy.Children.Add(button);
    }

    void button_Click(object sender, RoutedEventArgs e)
    {
       // some code which does not get executed!!!!
    }

【问题讨论】:

    标签: c# windows windows-8 windows-8.1


    【解决方案1】:

    删除

    button.IsHitTestVisible = false;
    

    或将其设置为true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-23
      • 1970-01-01
      相关资源
      最近更新 更多