WinRT Listview滚动不在网格中工作

时间:2015-07-23 17:49:46

标签: xaml listview windows-runtime grid windows-phone-8.1

好吧我有一个父网格,其中有三个其他网格。问题是我在最后一个里面有一个Listview。在此网格中,滚动列表视图项目不起作用。但是如果我在中间网格中移动相同的列表视图,则滚动工作正如我想要的那样。我在这里错过了什么?如何使Listview滚动在最后一个网格中工作。这是代码片段。 TIA

<Grid  x:Name="Container" Background="Transparent">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="HambugerMenuStateGroup">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0:0:0.3">
                    <VisualTransition.GeneratedEasingFunction>
                        <CubicEase EasingMode="EaseInOut"/>
                    </VisualTransition.GeneratedEasingFunction>
                </VisualTransition>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="HamburgerCloseState"/>
            <VisualState x:Name="HamburgerOpenState">
                <Storyboard>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    <DoubleAnimation Duration="0" To="380" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetX)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    <DoubleAnimation Duration="0" To="480" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetX)" Storyboard.TargetName="HamburerPane" d:IsOptimized="True"/>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="ManualDataPanelStateGroup">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0:0:0.3">
                    <VisualTransition.GeneratedEasingFunction>
                        <CubicEase EasingMode="EaseInOut"/>
                    </VisualTransition.GeneratedEasingFunction>
                </VisualTransition>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="ManualDataPanelCloseState"/>
            <VisualState x:Name="ManualDataPanelOpenState">
                <Storyboard>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetY)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    <DoubleAnimation Duration="0" To="-380" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetX)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    <DoubleAnimation Duration="0" To="-460" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetX)" Storyboard.TargetName="ManualDataPane" d:IsOptimized="True"/>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

    <Grid x:Name="HamburerPane"
          Margin="-480,0,0,0">
        <Grid.Projection>
            <PlaneProjection/>
        </Grid.Projection>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Width="400" HorizontalAlignment="Left">
            <TextBlock>Hello</TextBlock>
        </StackPanel>
    </Grid>

    <Grid x:Name="LayoutRoot">
        <Grid.Projection>
            <PlaneProjection/>
        </Grid.Projection>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="25"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>

        </Grid.ColumnDefinitions>
        <maps:MapControl Grid.RowSpan="3" Grid.ColumnSpan="3" x:Name="MapControl"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <!--<maps:MapItemsControl ItemTemplate="{StaticResource MapControlDataTemplate}" ItemsSource="{Binding}" >
            </maps:MapItemsControl>-->
        </maps:MapControl>

        <Slider x:Name="RotationSlider" Grid.Row="0" Grid.Column="1" Maximum="360" Value="{Binding Heading, ElementName=MapControl, Mode=TwoWay}" ></Slider>
        <Slider x:Name="PitchSlider" Grid.Row="1" Grid.Column="2" Orientation="Vertical" Maximum="65" Value="{Binding DesiredPitch, ElementName=MapControl, Mode=TwoWay}" ></Slider>
    </Grid>


    <Grid x:Name="ManualDataPane"
          Margin="0,0,-480,0">
        <Grid.Projection>
            <PlaneProjection/>
        </Grid.Projection>
        <ListView ItemsSource="{Binding Origins}" Height ="{Binding ElementName=ManualDataPane, Path=ActualHeight}" Width="400" HorizontalAlignment="Right">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <expaControl:ExpanderControl Width="400"
                    ItemsSource="{Binding Intersections}"
                    HeaderTemplate="{StaticResource CustomHeaderTemplate}"
                    ItemTemplate="{StaticResource CustomItemTemplate}" IsExpanded="False" Style="{StaticResource ExpanderControlStyle}" ExpanderTemplate="{StaticResource CustomExpanderTemplate}"/>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

    </Grid>

</Grid>

这三个网格位于父网格中。 grid.projection仅用于为汉堡菜单设置动画网格。没问题。

2 个答案:

答案 0 :(得分:0)

网格的行定义对于它所在的行是自动的。如果列表视图与auto一起放在一行它不会滚动你必须使用,1 ,2 *等或固定的高度。

答案 1 :(得分:0)

我最近发现当我将ListView放在一个带有<PlaneProjection/>的Container中时,滚动停止了工作。关闭PlaneProjection允许ListView再次滚动。这是你的问题吗?我现在正在寻找解决方案。