C# Windows Phone 8全景选择在浏览项目时索引不变

C# Windows Phone 8全景选择在浏览项目时索引不变,c#,xaml,windows-phone-7,windows-phone-8,panorama-control,C#,Xaml,Windows Phone 7,Windows Phone 8,Panorama Control,我已经从ItemSource创建了全景控件并绑定了全景项目。现在,当我通过滑动来更改选定的全景项目时,选定的索引始终设置为-1。我不知道在执行过程中我做错了什么。未触发selectionchange事件。 代码: PanoramaContainerItemStyle <Style x:Key="PanoramaContainerItemStyle" TargetType="phone:PanoramaItem"> <Setter Property="Hori

我已经从ItemSource创建了全景控件并绑定了全景项目。现在,当我通过滑动来更改选定的全景项目时,选定的索引始终设置为-1。我不知道在执行过程中我做错了什么。未触发selectionchange事件。 代码:


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>

我在这里看不到任何已执行/挂接的选择更改事件

SelectionChanged="Panorama_SelectionChanged"
您应该首先在全景级别定义此事件。
(不在PanoramaContainerItemStyle中)

在SelectionChanged事件处理程序中为SelectedItem分配null,以便每次都选择新项目。

检查SelectionChanged事件是否工作。否及其工作状态!你是什么意思?我的意思是,当我在手机上添加SelectionChange事件时:全景控件在我浏览全景项目时不会被触发。SelectionChange不会被触发有什么意义吗?请发布你的
PanoramaContainerItemStyle
SelectionChanged="Panorama_SelectionChanged"