我想在列表视图中显示图像,指针在图像上方,我将在图像底部显示文件大小/文件名和下载按钮。我也可以点击图片打开文件。
我注册了控件的PointerEntered和PointerExited事件,并在事件被触发时尝试显示或隐藏filesize / filename / download按钮。
当手指触摸图像时,会触发PointerEntered。但是,在触摸屏(手机,平板电脑)上,当手指离开图像时,不会触发PointerExited事件。当我在平板电脑上使用鼠标操作时,一切正常。
这是我的代码段:
<Grid>
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="PointerEntered" >
<Core:InvokeCommandAction Command="{Binding ShowFileInfoCommand}"></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="PointerExited" >
<Core:InvokeCommandAction Command="{Binding HideFileInfoCommand}"></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Image Source="{Binding ThumbnailUri}" Stretch="{Binding ImageStretch}" MaxHeight="200" MaxWidth="350" Height="{Binding FileHeight}" HorizontalAlignment="Right">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped" >
<Core:InvokeCommandAction Command="{Binding ConversationRoom.OpenFileFlipViewCommand,Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="RightTapped">
<Core:InvokeCommandAction Command="{Binding RightTappedMessageCommand}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Image>
<Grid Background="White" Opacity="0.75" Height="50" x:Name="InfoGrid" VerticalAlignment="Bottom" Visibility="{Binding NeedShowFileInfo, Converter={StaticResource BoolToVisible}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Margin="6,0,0,6" Text="{Binding FileName}"/>
<TextBlock Grid.Row="1" Margin="6,0,0,6" Text="{Binding FileSize}"/>
<FontIcon Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Margin="0,0,6,6" Glyph="" FontFamily="../Assets/fontello.ttf#fontello">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped">
<Core:InvokeCommandAction Command="{Binding DownloadCommand}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</FontIcon>
</Grid>
</Grid>
如果我将Grid移出listview,但是在stackpanel / Grid中,一切都很顺利。
有人可以帮忙解决这个问题吗? 谢谢!