none
ListView的选中项问题 RRS feed

  • 问题

  • 当我在ListView的区域外单击的时候,ListView会自动把第一项选中,这是怎么回事呢

     <ListView x:Name="CityListView" Padding="0,120,110,30" TabIndex="1"
                                  Style="{StaticResource ListViewStyle}"
                                  ItemsSource="{Binding Source={StaticResource CityItemsSource}}"
                                  ItemContainerStyle="{StaticResource SnapedCityStyle}"
                                  SelectionMode="Single"
                                  IsSwipeEnabled="False"
                                  IsSynchronizedWithCurrentItem="{x:Null}"
                                  IsItemClickEnabled="True"
                                  ItemClick="CityItem_Click"
                                  ScrollViewer.VerticalScrollBarVisibility="Disabled"
                                  ScrollViewer.VerticalScrollMode="Disabled">
                                <ListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <VirtualizingStackPanel Orientation="Vertical" />
                                    </ItemsPanelTemplate>
                                </ListView.ItemsPanel>
                                <ListView.GroupStyle>
                                    <GroupStyle>
                                        <GroupStyle.HeaderTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding CityGroupName}" Foreground="White" FontFamily="Microsoft YaHei"
                                               FontSize="28" Margin="0,0,0,6"/>
                                            </DataTemplate>
                                        </GroupStyle.HeaderTemplate>
                                    </GroupStyle>
                                </ListView.GroupStyle>
                            </ListView>

    2012年12月7日 2:02

答案

全部回复