Subhankar
Subhankar

Reputation: 507

Windows 8 app adding click event to HyperLinkButton doesnot work

I have some hyperlinkbutton for which I have added the click listener programmatically. But the code written in the event handler does not get called. Am I missing something? Below is the code

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

Upvotes: 0

Views: 237

Answers (1)

andreask
andreask

Reputation: 4298

Remove

button.IsHitTestVisible = false;

or set it to true

Upvotes: 3

Related Questions