0
更新2012年9月17日:重申這個問題,並加入娛樂步驟項目細節中的嵌套WrapGrid/GridView ScrollViewer?
我想一個WrapGrid風格的圖片庫添加到ItemDetailPage。到目前爲止,我發現實現此目的的唯一解決方案是創建組樣式並使用DataTemplate選擇器。這似乎是一個細節頁面做這件事矯枉過正,因爲我需要爲我的網頁上的每一列創建一個類。
我試圖解決這個問題,如下所示,但GridView獨立於我的ScrollViewer滾動,這是不可接受的。
要重新開始,在VS默認的網格應用:
添加此屬性SampleDataItem
// Add to SampleDataItem TODO: replace int with image url strings
private List<int> _subItems = null;
public List<int> SubItems
{
get
{
if (_subItems == null)
{
_subItems = new List<int>();
for (int i = 0; i < 50; i++)
this._subItems.Add(i);
}
return this._subItems;
}
set { this.SetProperty(ref this._subItems, value); }
}
在ItemDetailPage.xaml
在ScrollViewer中更換RichTextColumns:
<!--Fixed column layout, replaces RichTextColumns from template-->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="800"/>
<ColumnDefinition Width="1400"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="{Binding Title}"/>
<Image x:Name="image" MaxHeight="480" Margin="0,20,0,10" Stretch="Uniform" Source="{Binding Image}"/>
</StackPanel>
<GridView ScrollViewer.HorizontalScrollMode="Disabled" VerticalAlignment="Top" ItemsSource="{Binding SubItems}" Grid.Column="1" ItemTemplate="{StaticResource GridViewDataTemplate1}" >
</GridView>
</Grid>
最後添加以下DataTemplate
<DataTemplate x:Key="GridViewDataTemplate1">
<Grid Background="Yellow" Width="200" Height="200"/>
</DataTemplate>
將其設置爲「禁用」不適用於我。我重申了我的問題並提供了娛樂步驟。 – kbeal2k
kbeal2k:我發現你不能將一個GridView放置到一個ScrollViewer中,但是你可以將許多VariableSizedWrapGrids放入StackPanel –