我在一個ScrollViewer中的內部應用程序啓用捕捉點,在這個問題描述:Enabling ScrollViewer HorizontalSnapPoints with bindable collection捕捉的ScrollViewer在Windows 8 Metro在寬屏幕沒有捕捉到最後一項
是我遇到的問題是,我正在嘗試我的應用程序在全高清顯示器(1920x1080),每個項目是1400像素寬度。當我在項目#n-1中滾動滾動時,我無法滾動到最後一個,因爲它不會捕捉到...
我必須做的破解是添加一個「假」項,透明底,這樣我就可以滾動到我的收藏的最後一個項目:
<Page.Resources>
<Style x:Key="ItemsControlStyle" TargetType="ItemsControl">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer Style="{StaticResource HorizontalScrollViewerStyle}" HorizontalSnapPointsType="Mandatory" HorizontalSnapPointsAlignment="Near">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<ItemsControl Style="{StaticResource ItemsControlStyle}">
<Border Background="Red" Height="1000" Width="1400"/>
<Border Background="Blue" Height="1000" Width="1400"/>
<Border Background="Green" Height="1000" Width="1400"/>
<Border Background="Yellow" Height="1000" Width="1400"/>
<Border Background="Magenta" Height="1000" Width="1400"/>
<Border Background="Transparent" Height="1000" Width="1000" />
</ItemsControl>
,我不得不即使使用此技巧的第二個問題,是從metro應用我不」無法訪問屏幕大小,所以我甚至無法添加具有可變寬度的最後一項,具體取決於屏幕以解決此問題。有什麼建議麼?
謝謝!
您如何找到更好的解決方案?當你的意思是改變寬度時,它是否真的使最後一個項目看起來比其他項目更小? –