首页 新闻 会员 周边

Windows Phone, 点击控件的空白处, tap事件没被触发。

0
悬赏园豆:100 [待解决问题]

我给Grid注册了tap事件,目前的情况是这样的:

1)点击image/textblock时,tap事件能捕获到。

2)点击空白区域时,tap事件没有捕获到。

xaml:

<Grid x:Name="LayoutRoot" Tap="viewAccount">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Image Stretch="None" Source="/Assets/Account.png" Grid.Row="0" Grid.Column="0" />
    <TextBlock Text="My Account Information" Grid.Row="0" Grid.Column="1" />
</Grid>

 

c#事件处理代理:

private void viewAccount(object sender, System.Windows.Input.GestureEventArgs e)
{
    MessageBox.Show("view account");
}

 

效果图:

红色空白区域,点击事件不工作。

点击图中的红色空白区域,tap事件没有捕获到,是什么原因呢。?

UsernameNotFound的主页 UsernameNotFound | 初学一级 | 园豆:119
提问于:2013-03-27 20:09
< >
分享
所有回答(2)
0

我觉得是因为红色空白区域是空的,没有“东西”,WP不会渲染,自然不会触发事件。就像Image控件一样,有宽度、有高度,Background为空,也不会渲染,Image的所有事件也不会触发。

ljpass6754 | 园豆:192 (初学一级) | 2013-03-29 23:11
0

设置Background为透明,没有填充的布局控件不能触发点击事件额

sun8134 | 园豆:98 (初学一级) | 2013-09-23 20:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册