.Gridview not scrolling horizontally in windows phone app instead it is scrolling vertically.I just copy paste the code of my windows 8.1 app to windows phone 8.1 but it is scrolling vertically.
here is the xaml code:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="Assets/back3.png"></ImageBrush>
</Grid.Background>
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height=".6*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Select Comic" Foreground="Black" FontSize="30" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1"></TextBlock>
<!-- Back button and page title -->
<GridView x:Name="myGridview" Grid.Column="1" Grid.Row="1" SelectionChanged="myGridview_SelectionChanged">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
Try by putting
ItemsPanel
,ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible"
<GridView Width="400" ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Update
try by changing Itemspanel : WrapGrid Orientation="Vertical" or Orientation="Horizontal"
<GridView Width="400" ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"></WrapGrid>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With