0
如何獲取(或循環)GridView中的所有項目?下面的XAML生成的可點擊我需要能夠遍歷這些元素並更新它們的值項/點擊在GridView中獲取項目Windows 8
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.RowSpan="2"
Padding="116,136,116,46"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
SelectionMode="None"
IsSwipeEnabled="false">
<GridView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left" Width="250" Height="250" Tapped="Grid_Tapped" RightTapped="Grid_RightTapped">
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding ImageURL}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
</Border>
<StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Name}" Foreground="{ThemeResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" Height="60" Margin="15,0,15,0" FontWeight="SemiBold"/>
<TextBlock Text="{Binding CurrentState}" Foreground="{ThemeResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" TextWrapping="NoWrap" Margin="15,0,15,10" FontSize="12"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
的網格。這是我嘗試這樣做,但不能
foreach (var item in itemGridView.Items)
{
var _Container = itemGridView.ItemContainerGenerator.ContainerFromItem(item);
//Once i have the contrainer i know i can access its childern but this line of code throws error
}
有沒有一種辦法能夠做什麼,我想在這裏做什麼?
或者如果在Windows 8中有RowDataBound事件?
返回null。 – Salman