如何从PanoramaItem中的ViewBox获取WP8.1上的选定索引或项目?这是我的xaml和我的c#代码
XAML
<phone:PanoramaItem Orientation="Horizontal" Background="White">
<!--Double wide Panorama with large image placeholders-->
<Viewbox x:Name="Myitem" Height="800" Margin="0,-30,0,0" Width="912" >
<Border Height="800" Width="912">
<ScrollViewer Margin="0,0,0,177">
<StackPanel Margin="0,0,16,0" Orientation="Vertical" VerticalAlignment="Top" Height="1722">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<Border Height="100" Width="100" Margin="12,0,0,0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/Tiles/stib-pic0.gif"/>
</Border.Background>
</Border>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0,12,0,0">
<Border Height="100" Width="100" Margin="12,0,0,0" Tap="Border_Tap">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/Tiles/stib-pic1.gif"/>
</Border.Background>
</Border>
<Border Height="100" Width="100" Margin="12,0,0,0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/Tiles/stib-pic2.gif"/>
</Border.Background>
</Border>
<Border Height="100" Width="100" Margin="12,0,0,0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/Tiles/stib-pic3.gif"/>
</Border.Background>
</Border>
<Border Height="100" Width="100" Margin="12,0,0,0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/Tiles/stib-pic4.gif"/>
</Border.Background>
</Border>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Border>
</Viewbox>
</phone:PanoramaItem>
C#点击事件
private void Border_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
MessageBox.Show("Tapped!: " + "(number) item");
}
我可以在互联网上找到一些提示,但它们都是LongListSelector
答案 0 :(得分:0)
您想要获取所选项目的哪个控件? 如果它是Panorama,那么您可以为包含PanoramaItem的Panorama控件指定名称并使用Panorama.SelectedIndex属性。
我对已发布的XAML没有任何其他控件,它具有所选项目的概念......
答案 1 :(得分:0)
首先,您必须提供全景项目的标题名称,以便轻松获取所选标题。然后在全景选择更改事件上调用此代码段。
var selectedItem = (PanoramaItem)(sender as Panorama).SelectedItem;
string item=selectedItem.Header.ToString();