Reputation: 507
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