Windows应用商店ListView控件的问题

时间:2014-02-21 20:55:52

标签: .net windows windows-store-apps windows-8.1

我在Windows商店应用8.1中需要一些关于Listview的专家帮助。目前我在Listview中垂直显示150个项目,默认属性设置为启用,如

IsSwipeEnabled =“True”IsTapEnabled =“True”SelectionMode =“Single”CanDragItems =“True”CanReorderItems =“True”

使用上面的设置,一切都很好, 当屏幕加载时,我看到默认选择列表视图中的第一项,如何删除默认选择。我设置seletedindex = -1和selecteditem = null,坚果已经有效。

当我设置SelectionMode =“none”IsTapEnabled = False且IsItemClickEnabled =“True”时 我没有看到第一个项目被选中。但现在我触摸事件没有被解雇。

第二个问题是我的列表视图项目是可拖动的,每次我选择/点击一个项目并拖动到网格的右侧。我的整个Listview浮动或移动,我想使Listview固定在位,当我拖动单个ListViewItem时不应该拖动整个列表视图。这对用户造成了烦扰。我希望listview被修复,即它不应该移动@时间选择和拖动项目。请给我一些建议。

    <SemanticZoom x:Name="semanticZoom" VerticalAlignment="Bottom" Grid.Row="4"   HorizontalAlignment="Left"    Style="{x:Null}"
              >
        <SemanticZoom.ZoomedOutView>
            <GridView  IsItemClickEnabled="False"  IsSwipeEnabled="False"     ScrollViewer.IsHorizontalScrollChainingEnabled="False"  Style="{x:Null}">
                 <GridView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ItemsWrapGrid ItemWidth="75" Orientation="Horizontal" ItemHeight="75" MaximumRowsOrColumns="5"  Background="Transparent" />
                    </ItemsPanelTemplate>
                </GridView.ItemsPanel>
             </GridView>
        </SemanticZoom.ZoomedOutView>
        <SemanticZoom.ZoomedInView>
            <ListView x:Name="ItemsGridView" IsSwipeEnabled="True"  SelectionMode="Single" IsTapEnabled="True" VerticalAlignment="Stretch"  MaxHeight="725"
              ItemsSource="{Binding Source={StaticResource GrpColumns},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
              Height="Auto"
              ScrollViewer.VerticalScrollBarVisibility="Auto"  AllowDrop="True"     Drop="ItemsGridView_Drop"
             Tag="{Binding Path=Columns,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
              ScrollViewer.VerticalScrollMode="Auto"   CanDragItems="True" CanReorderItems="True" IsItemClickEnabled="True"   >
                <interactivity:Interaction.Behaviors>
                    <behaviors:DragBehaviour/>
                </interactivity:Interaction.Behaviors>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid  Margin="10,2,0,2" HorizontalAlignment="Stretch"     >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="3*"></ColumnDefinition>
                                <ColumnDefinition Width="97*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock   Text="{StaticResource AsterikGlyph}"  
                                             Style="{StaticResource GlyphIconStyle}"   Margin="0,2,0,0"   
                                             FontFamily="{StaticResource SymbolThemeFontFamily}"
                                            HorizontalAlignment="Center" VerticalAlignment="Top" 
                                Visibility="{Binding Path=IsRequireField,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource TextBlockVisibityConverter}}" />

                            <TextBlock Text="{Binding SrcName}"  TextTrimming="WordEllipsis"  Margin="2,0,0,2" TextWrapping="NoWrap"
                                   Style="{StaticResource SemantizZoomOutViewTextBlock}"  Grid.Column="1"       ToolTipService.ToolTip="{Binding SrcName}"                                     
                                       VerticalAlignment="Center" HorizontalAlignment="Left">

                            </TextBlock>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <ItemsPanelTemplate>
                    <ItemsStackPanel Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Standard" />
                </ItemsPanelTemplate>          
                <ListView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>                               
                            <DataTemplate>
                                <Border Background="#333F50" Margin="4" BorderBrush="Transparent" BorderThickness="1" Width="60" Height="60">
                                    <Button x:Name="HeaderButton"  Background="Transparent" Width="60" Height="60"  Padding="1" HorizontalAlignment="Center" VerticalAlignment="Center" Click="HeaderButton_Click">
                                        <TextBlock Text="{Binding Key}" Margin="2"  Style="{StaticResource GroupHeaderTextStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                    </Button>   
                                </Border>
                            </DataTemplate>                               
                        </GroupStyle.HeaderTemplate>
                    </GroupStyle>
                </ListView.GroupStyle>
            </ListView>
        </SemanticZoom.ZoomedInView>
    </SemanticZoom>

1 个答案:

答案 0 :(得分:0)

我认为您可以使用getter和setter将ListView的选定项绑定到属性。在设置器中取一个断点,您可以在调用堆栈中检查设置默认值的原因。原因据我所知,ListView上没有默认选择。

关于第二个问题,我可以检查一下ListView和它的父母吗?在Codepact或类似的东西。