Max Marchuk
Max Marchuk

Reputation: 63

WP7: Button Tap event not firing, why?

I'm using WP7 'Mango' SDK and Phone Toolkit for my app. I have a control, which contains ExpanderView. I'm using next template for ExpanderView's header:

<toolkit:ExpanderView.HeaderTemplate>  
    <DataTemplate>  
        <StackPanel Orientation="Horizontal">  
            <TextBlock Text="{Binding Name}"/>  
            <Button Tap="ShowMoreTap">  
                <Button.Template>  
                    <ControlTemplate>  
                        <TextBlock Text="show more..."/>  
                    </ControlTemplate>  
                </Button.Template>  
            </Button>  
        </StackPanel>  
    </DataTemplate>  
</toolkit:ExpanderView.HeaderTemplate>  

The code behind:

private void ShowMoreTap(object sender, System.Windows.Input.GestureEventArgs e)
{
    // Some logic here
}  

I don't want to expand/collapse the ExpanderView when user taps on the button, I need some specific actions there. The problem is that ShowMoreTap event is never fired.

Any ideas?
Thanks

Upvotes: 0

Views: 805

Answers (1)

Emond
Emond

Reputation: 50672

According to the source code the Tap is handled by the ExpanderView to cause the expansion (or collapse)

Apparently this event then never bubbles up; it is not a routed event.

I see two options:

  1. using the source code from codeplex make a customized version of the ExpanderView or
  2. stop using the ExpanderView because you do not want to expand anything. You could probably switch to another control that you style similarly more easily. Remember: do not use a control because it looks the way you want it, use it because it has the properties and behavior you need. WP7 allows you to style any control.

Upvotes: 2

Related Questions