我创建了全景控件,并从ItemSource绑定了ItemSource。现在,当我通过滑动来改变所选的全景项目时,所选的索引总是设置为-1。我不知道我在执行过程中做错了什么。两个选择更改事件都不会被解雇。代码:
<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>发布于 2014-05-07 08:54:14
我在这里看不到任何Selection_Changed事件的实现/钩住。
SelectionChanged="Panorama_SelectionChanged"您应该首先在全景级别上定义此事件。(不在PanoramaContainerItemStyle内)
发布于 2014-05-07 12:01:10
最后在SelectedItem事件处理程序中将null赋值给SelectionChanged,这样每次都会选择新的项。
https://stackoverflow.com/questions/23491238
复制相似问题