使用ItemClick内部网格的Gridview

时间:2013-03-08 09:11:27

标签: windows gridview styles microsoft-metro

单击图块时不执行我的ItemView_ItemClick(除非我单击矩形选择器)。

为什么?我怎样才能做到这一点 ?感谢。

<GridView Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Products}" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick">
    <GridView.ItemTemplate>
        <DataTemplate>
            <GridViewItem>
                <Grid Width="300" Height="200">
                    <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
                        <Image Source="{Binding SmallPic, Converter={StaticResource imageConverter }}" Stretch="UniformToFill"/>
                    </Border>
                    <StackPanel VerticalAlignment="Bottom" Opacity="1" Background="#7F000000" >
                        <TextBlock Text="{Binding Name}" Style="{StaticResource ItemContentStyle}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"  Margin="15,0,15,0"/>
                        <TextBlock Text="{Binding Price, Converter={StaticResource priceConverter }}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
                    </StackPanel>
                </Grid>
            </GridViewItem>
        </DataTemplate>
    </GridView.ItemTemplate>
</GridView>

1 个答案:

答案 0 :(得分:0)

将我的评论转移到答案....

<GridViewItem>包含是不必要的,似乎导致了不必要的行为。