Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridview not scrolling horizontally in windows phone 8.1

.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>
like image 283
Ghazanfar Khan Avatar asked Jul 10 '14 13:07

Ghazanfar Khan


1 Answers

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>
like image 198
Heena Avatar answered Oct 16 '22 17:10

Heena