Windows phone 8 WP8:非活动全景项目即使在未活动时也可点击
使用“全景”控件时,非活动全景项目中的元素会响应点击事件。您可以使用下面的XAML重现这一点,该XAML只是从WindowsPhone8SDK附带的Panorama应用程序解决方案模板稍作修改。您可以查看第二个全景项目中的项目如何可点击,即使该全景项目未处于活动状态Windows phone 8 WP8:非活动全景项目即使在未活动时也可点击,windows-phone-8,windows-phone,panorama-control,Windows Phone 8,Windows Phone,Panorama Control,使用“全景”控件时,非活动全景项目中的元素会响应点击事件。您可以使用下面的XAML重现这一点,该XAML只是从WindowsPhone8SDK附带的Panorama应用程序解决方案模板稍作修改。您可以查看第二个全景项目中的项目如何可点击,即使该全景项目未处于活动状态 <phone:Panorama Title="my application"> <phone:Panorama.Background> <ImageBrush ImageSour
<phone:Panorama Title="my application">
<phone:Panorama.Background>
<ImageBrush ImageSource="/PanoramaApp1;component/Assets/PanoramaBackground.png"/>
</phone:Panorama.Background>
<!--Panorama item one-->
<phone:PanoramaItem Header="first item">
<!--Single line list with text wrapping-->
<phone:LongListSelector Margin="0,0,-22,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,-6,0,12">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeExtraLarge}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PanoramaItem>
<!--Panorama item two-->
<phone:PanoramaItem>
<!--Double line list with image placeholder and text wrapping using a floating header that scrolls with the content-->
<phone:LongListSelector Margin="0,-38,-22,2" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="12,2,0,4" Height="105" Width="432" Tap="SecondItem_OnTap">
<!--Replace rectangle with image-->
<Border BorderThickness="1" Width="99" Height="99" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
<StackPanel Width="311" Margin="8,-7,0,0">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Margin="10,0" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeLarge}" />
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="10,-2,10,0" Style="{StaticResource PhoneTextSubtleStyle}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PanoramaItem>
</phone:Panorama>
请注意第二个全景项目中LongListSelector.ItemTemplate中的“SecondItem_OnTap”点击事件处理程序连接
我在所有未预装在手机上的应用程序中都观察到了这种行为,换句话说,所有非微软应用程序,包括Facebook和Pandora等应用程序。有人有吗
这很麻烦,但您可以捕获全景的SelectionChanged事件并禁用可单击元素 是的,这是一个众所周知的全景控制问题。我们在一个应用程序中解决了这个问题,在不活动的全景项目上创建了透明覆盖。这种方法的缺点是,如果在覆盖层顶部开始侧扫,手势将被忽略。对于我们最新的应用程序,我们只是忽略了这种行为。如果微软担心的话,他们会解决的。至于原因,微软显然没有在他们的应用程序中使用标准的手机控件。谢谢大家的回答!我用以下方法解决了这个问题:
private void Panorama_OnSelectionChanged(object sender, SelectionChangedEventArgs e) {
this.UpdateHitTestForPanoItems(this.Panorama.SelectedItem);
}
private void Panorama_OnLoaded(object sender, RoutedEventArgs e) {
this.UpdateHitTestForPanoItems(this.Panorama.SelectedItem ?? this.Panorama.Items.FirstOrDefault());
}
private void UpdateHitTestForPanoItems(object selectedItem) {
foreach (PanoramaItem item in this.Panorama.Items) {
item.IsHitTestVisible = item == this.Panorama.SelectedItem;
}
}
当然,您需要将Loaded
和SelectionChanged
事件分别连接到Panorama\u onload
和Panorama\u OnSelectionChanged
方法。我还可以看到将其移动到行为
,您可以在应用程序中的其他全景图上使用