0

I have created Panorama control and binded PanoramaItem from ItemSource. Now when i am changing the selected Panoramaitem by swiping over them the Selected index is always set to -1. I dont know what wrong i am doing while implementation. neither selectionchange event is getting fired. Code:

<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>
Balraj Singh
  • 3,381
  • 6
  • 47
  • 82

2 Answers2

0

I can't see any Selection_Changed event implemented/hooked here.

SelectionChanged="Panorama_SelectionChanged"

You should at first define this event on Panorama level. (Not inside the PanoramaContainerItemStyle)

halil
  • 326
  • 1
  • 6
0

assign null to SelectedItem at last in SelectionChanged event handler, so that new item will get selected every time.

vITs
  • 1,651
  • 12
  • 30