Windows Phone 8全景选择索引在浏览项目时没有更改



我已经创建了Panorama控件并从ItemSource绑定了PanoramaItem。现在,当我通过在选定的全景上滑动来更改它们时,选定的索引总是设置为-1。我不知道在执行过程中我做错了什么。两个selectionchange事件都没有被激发。代码:

<phone:Panorama Grid.Row="1"  Visibility="Visible"
       x:Name="PnrVwMainNews"
       ItemsSource="{Binding ParnormaItemsData}"
       ItemContainerStyle="{StaticResource PanoramaContainerItemStyle}">
    <phone:Panorama.ItemTemplate>
        <DataTemplate>
            <!-- Panorma Items Template -->
            <Controls:DynamicContentControl Content="{Binding UsrCntrlDynamic}" />
        </DataTemplate>
    </phone:Panorama.ItemTemplate>
</phone:Panorama> 

PanoramaContainerItemStyle

<Style x:Key="PanoramaContainerItemStyle" TargetType="phone:PanoramaItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="phone:PanoramaItem">
                    <Grid Background="{TemplateBinding Background}" Margin="12,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Grid.Row="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

我看不到任何Selection_Changed事件在这里实现/挂起。

SelectionChanged="Panorama_SelectionChanged"

您首先应该在"全景"级别定义此事件。(不在PanoramaContainerItemStyle内(

在SelectionChanged事件处理程序中最后为SelectedItem赋值null,这样每次都会选择新项。

相关内容

最新更新