XAML:使用语义缩放和ListView MakeVisible不会滚动

时间:2012-11-15 08:47:45

标签: listview window microsoft-metro winrt-xaml semantic-zoom

我有一个嵌入在语义缩放控件中的ListView控件:

<SemanticZoom x:Name="diarySemanticZoom" Grid.Row="1">
            <SemanticZoom.ZoomedOutView>
                <GridView>
                    ...
                </GridView>
            </SemanticZoom.ZoomedOutView>
            <SemanticZoom.ZoomedInView>
                    <ListView 
                        x:Name="diaryListView" 
                        AutomationProperties.AutomationId="diaryListView"
                        AutomationProperties.Name="Grouped Items"
                        Grid.Row="1" 
                        ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
                        SelectionMode="Single" 
                        ScrollViewer.IsHorizontalScrollChainingEnabled="False"
                        ScrollViewer.IsVerticalScrollChainingEnabled="False"
                        ScrollViewer.HorizontalScrollBarVisibility="Visible"
                        >
                        <ListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapGrid Orientation="Vertical" 
                                MaximumRowsOrColumns="1" x:Name="insideWrapGrid"/>
                        </ItemsPanelTemplate> ...

当XAML加载时我想滚动到Listview中的项目

protected override void LoadState(Object navigationParameter, 
                     Dictionary<String, Object> pageState)
{
    var diaryDaysModel = DiaryDays.DiaryDayList;
    /* Group the days */
    var daysViewModelGroup = from ddm in diaryDaysModel
                             group ddm by new { ddm.MonthName, ddm.DayNo } into grp
                             orderby grp.Key.DayNo
                             select new { Key = grp.Key, Items = grp };

    itemsViewSource.Source = daysViewModelGroup;
    diaryListView.SelectedIndex = 5;
    var zoomLoc = new SemanticZoomLocation() { Item = diaryListView.SelectedItem };
    diarySemanticZoom.ZoomedInView.MakeVisible(zoomLoc);
    diaryListView.MakeVisible(zoomLoc);

}

到目前为止,我尝试了很多选项,但似乎没有任何选项可以移动滚动

1 个答案:

答案 0 :(得分:1)

你应该能够滚动。 如果要垂直滚动,请编辑ScrollViewer.IsVerticalScrollBarEnabled =“已启用”。