Snapping ScrollViewer in Windows 8 Metro in Wide screens not snapping to the last item

可紊 提交于 2019-12-05 23:38:40

It seems that changing programmatically the width of the last item is the best solution, using Window.Current.Bounds.Width;

Ian Walker

I found you can access the current screen size from within LayoutAwarePage.cs using the WindowSizeChanged event (e.Size)

That said, I'm sure there is probably a better way of accessing this event.

Domoch

Solution provided before was correct just for small amount of cases (items with fixed sizes) and has issues with visual view.

UPDATE: See example here Enabling ScrollViewer HorizontalSnapPoints with bindable collection

No "fake" items needed, as for the second: you do not need screen size just ItemsPresenter.Parent.ActualHeight(or Width, depending on used orientation of list) and items container width - see example.

chuanged HorizontalSnapPointsAlignment when ViewChanging , like this :

private void sv_ViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
    {
        if (e.NextView.HorizontalOffset <e.FinalView.HorizontalOffset)
        {
            sv.HorizontalSnapPointsAlignment = SnapPointsAlignment.Far;
        }
        else if (e.NextView.HorizontalOffset > e.FinalView.HorizontalOffset)
        {
            sv.HorizontalSnapPointsAlignment = SnapPointsAlignment.Near;
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!