Ste*_*ner 11 silverlight scroll windows-phone-7
我正在尝试使用下面的代码在WP7 silverlight中创建一个水平列表框.项目水平显示但滚动仍然是垂直的.
我在wpf做错了吗?这是WP7特有的错误吗?
<Style TargetType="ListBox" x:Name="HorizontalListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"
IsItemsHost="True"
CanHorizontallyScroll="True"
CanVerticallyScroll="False"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
编辑:我错过了两个似乎有很大不同的属性.(解决方案来自Mick N接受的答案中的第二个链接.)
<Style TargetType="ListBox" x:Name="HorizontalListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" CanHorizontallyScroll="True" CanVerticallyScroll="False"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
</Style>
Run Code Online (Sandbox Code Playgroud)
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >
<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,6,-196,0" Height="Auto" Name="imageScroll">
<ListBox x:Name="imageBox" Margin="12,0,0,0">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation ="Horizontal" >
<StackPanel.RenderTransform>
<TranslateTransform
X="0" />
</StackPanel.RenderTransform>
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Avatar}" Width="240" Stretch="Fill" Height=" 100" />
<!--<TextBlock TextWrapping="Wrap" Text="{Binding Titulo}" FontSize="35" VerticalAlignment="Center" Margin="0,10" />-->
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)
这是适合我的代码.
| 归档时间: |
|
| 查看次数: |
10505 次 |
| 最近记录: |