【发布时间】:2012-06-18 14:00:41
【问题描述】:
我已在 ScrollViewer 内的应用中启用捕捉点,如以下问题所述:Enabling ScrollViewer HorizontalSnapPoints with bindable collection
我遇到的问题是,当我在全高清显示器 (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>
我什至使用此 hack 时遇到的第二个问题是,我无法从 Metro 应用程序访问屏幕大小,因此我什至无法添加取决于屏幕的可变宽度的最后一项来解决这个问题。有什么建议吗?
谢谢!
【问题讨论】:
标签: windows xaml microsoft-metro