【发布时间】:2014-01-29 16:18:14
【问题描述】:
我有这个 ScrollViewer,在一个 Windows Phone 8 项目中
<ScrollViewer Name="MediaScroll" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" Background="#7FD13E3E" Tap="ScrollViewer_Tap" VerticalAlignment="Top" LayoutUpdated="MediaScroll_LayoutUpdated">
<ItemsControl ItemTemplate="{StaticResource ItemTemplate2}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" ItemsSource="{Binding listaMedia}">
</ItemsControl>
</ScrollViewer>
使用这些模板的人
<phone:PhoneApplicationPage.Resources>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="ItemTemplate2">
<StackPanel Width="480">
<Image Source="/Assets/play@2x.png" Width="75" Canvas.ZIndex="10" Margin="203,85,202,0" />
<Image Source="{Binding snapshot.path}" Stretch="Fill" VerticalAlignment="Top" Margin="0,-160,0,0" />
</StackPanel>
<!--<Image Tag="{Binding id}" Source="{Binding snapshot.path}" Width="150" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="-10,0,-9,0" Tap="Image_Tap" />-->
<!--Your other code-->
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
我得到一个包含图像的列表,滚动显示它们水平。 当我滚动时,我想 ScrollViewer 捕捉到最近的图像,这意味着如果滚动显示 2 个图像的一部分,它会自动滚动到最近的图像并显示该图像。 我不希望滚动基本上显示 2 个图像的 2 个一半
不确定我是否可以通过 LayoutUpdated 事件做到这一点。
【问题讨论】:
标签: xaml windows-phone-8 windows-phone scrollviewer