파노라마 컨트롤에 대한 항목 템플릿이 있습니다. 이 템플릿에는 listItem 템플릿이있는 listbox가 있습니다. 목록 상자에서 선택 변경 이벤트에 문제가 있습니다.Windows Phone 용 panorama.ItemTemplate의 ListBox에 대한 SelectionChanged 이벤트?
<phone:PhoneApplicationPage.Resources>
<CollectionViewSource x:Key="SlideItemList" Filter="collectionView_Filter"/>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Panorama control-->
<controls:Panorama x:Name="AppPano" ItemsSource="{Binding SlidesCollections}" SelectionChanged="AppPano_SelectionChanged" >
<controls:Panorama.Background>
<ImageBrush ImageSource="PanoramaBackground.png"/>
</controls:Panorama.Background>
<controls:Panorama.ItemTemplate>
<DataTemplate>
<Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,-100,0,0">
<StackPanel HorizontalAlignment="Center" Height="250" Width="200" VerticalAlignment="Top">
<TextBlock Text="{Binding Title}" HorizontalAlignment="Center" FontSize="200" Width="Auto"/>
</StackPanel>
<ListBox x:Name="ItemsList" ItemsSource="{Binding Source={StaticResource SlideItemList}}" Margin="0,250,0,0" VerticalAlignment="Top" SelectionChanged="ItemsList_SelectionChanged" Height="430">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="ImgStack" HorizontalAlignment="Left" Height="430" VerticalAlignment="Top" Width="370" Margin="50,0,0,0">
<Image Height="350" Width="360" Source="{Binding Image}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DataTemplate>
</controls:Panorama.ItemTemplate>
</controls:Panorama>
</Grid>
Xaml.cs
private void keyItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listbox = (ListBox)sender;
var conGen = listbox.ItemContainerGenerator;
var item = (UIElement)conGen.ContainerFromIndex(listbox.SelectedIndex);
if (item != null)
{
int selectedItemList = listbox.SelectedIndex;
if (sLasListItem != selectedItemList)
{
// navigate to another page
sLasListItem = selectedItemList;
}
}
}
바인딩 UI 요소가 완벽하게 작동합니다.
문제점 : 하나의 파노라마 항목 페이지의 목록에서 새 항목을 선택하면 해당 항목이 모든 파노라마 항목에 대해 동일한 선택 변경 이벤트를 발생시킵니다.
예 : 4 가지 파노라마 항목이 있습니다. 첫 번째 파노라마 항목 목록 상자에서 두 번째 항목을 선택했습니다. 이 선택 변경 이벤트가 4 번 실행되었습니다.
목록에서 새 항목을 선택하면 해당 파노라마 항목에 대해 한 번만이 이벤트가 실행됩니다. 같은 목록 4 번을 결합하고 있기 때문에
Pls는 저를 제안, 그것을 어떻게 ...
각 파노라마 컨트롤과 각 목록 상자에는 고유 한 선택 이벤트가 할당되어 있습니까? – earthling