WP7:按钮点击事件没有解雇,为什么?

时间:2012-01-25 15:11:28

标签: windows-phone-7 silverlight-toolkit

我正在为我的应用使用WP7'Mango'SDK和Phone Toolkit。我有一个控件,其中包含ExpanderView。我正在为ExpanderView的标题使用下一个模板:

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

背后的代码:

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

当用户点击按钮时,我不想展开/折叠ExpanderView,我需要一些特定的操作。问题是ShowMoreTap事件永远不会被触发。

任何想法?
感谢

1 个答案:

答案 0 :(得分:2)

According to the source code Tap由ExpanderView处理以引起扩展(或崩溃)

显然这个事件从未冒泡过;它不是一个路由事件。

我看到两个选项:

  1. 使用codeplex的源代码制作ExpanderView或
  2. 的自定义版本
  3. 停止使用ExpanderView,因为您不想展开任何内容。您可以切换到另一个控件,您可以更轻松地设置样式。请记住:不要使用控件,因为它看起来像你想要它,使用它,因为它具有你需要的属性和行为。 WP7允许您设置任何控件的样式。
相关问题