是否有人知道是否有可能在Windows Phone 8.1上創建水平列表視圖或gridview?WPF Horisontal listview
我試圖使一個與此片的XAML代碼,它給出了一個垂直取向的列表視圖:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HorzListView"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:SampleData="using:Blend.SampleData.SampleDataSource"
x:Class="HorzListView.MainPage"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<SampleData:SampleDataSource x:Key="SampleDataSource" d:IsDataSource="True"/>
<DataTemplate x:Key="ListDataItemTemplate">
<Grid>
<Image Source="{Binding Property3}" Height="79" Width="79"/>
</Grid>
</DataTemplate>
</Page.Resources>
<Grid DataContext="{Binding Source={StaticResource SampleDataSource}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Hello" FontSize="72"></TextBlock>
<ListView Grid.Row="1"
ItemTemplate="{StaticResource ListDataItemTemplate}"
ItemsSource="{Binding ListData}">
<!--<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>-->
</ListView>
</Grid>
如果我去掉下面的代碼塊,列表視圖得到水平,但它是不可能通過任何項目的滾動:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
我覺得它有什麼做的StackPanel中的ItemsPanel,因爲如果我改變方向ŧ o「垂直」它是垂直佈局,但滾動不可能。
有什麼建議嗎?
我用幾乎一模一樣的設置。在ItemsPanelTemplate中使用'VirtualizingStackPanel'而不是'StackPanel';這將啓用滾動。 – 2015-02-10 19:26:57