change a listview orinentation, when the devices change orientation

Viewed 28

I am trying to do this

When the device orientation changes to landscape layout, the list should scroll horizontally, not vertically. I know that I can use a ColectionView, but I HAVE to us a list

in the specification I have

  • Using the ListView Page:
  • When the device orientation changes to landscape layout, the list should scroll horizontally, not vertically (long-press to present the user with a "do you want to delete? dialog")

I don't know how to change the orientation of a listview

I used the synfusion list, but I think, they want me to use the Xamarin List

   protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);

            {
                base.OnSizeAllocated(width, height);

                if (width < height)
                {
                    // portrait orientation
                }
                else if (height < width)
                {
                    // landscape orientation
                }
            }

     <ListView
            x:Name="CarsList"
            Grid.Row="1"
            HasUnevenRows="True"
            ItemsSource="{Binding Cars}"
            SelectionMode="None"
            SeparatorVisibility="Default">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <SwipeView>
                            <SwipeView.RightItems>
                                <SwipeItems Mode="Execute">
                                    <SwipeItem BackgroundColor="Red"
                                               Command="{Binding Source={x:Reference ListPage}, Path=BindingContext.DeleteCommand}"
                                               CommandParameter="{Binding .}"
                                               Text="Delete" />
                                </SwipeItems>
                            </SwipeView.RightItems>
                            <local:CarView
                                Padding="0,10,0,0"
                                xct:TouchEffect.Command="{Binding Source={x:Reference ListPage}, Path=BindingContext.PressedCommand}"
                                xct:TouchEffect.CommandParameter="{Binding .}"
                                xct:TouchEffect.LongPressCommand="{Binding Source={x:Reference ListPage}, Path=BindingContext.LongPressedCommand}"
                                xct:TouchEffect.LongPressCommandParameter="{Binding .}" />
                        </SwipeView>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage.Content>     <ListView
            x:Name="CarsList"
            Grid.Row="1"
            HasUnevenRows="True"
            ItemsSource="{Binding Cars}"
            SelectionMode="None"
            SeparatorVisibility="Default">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <SwipeView>
                            <SwipeView.RightItems>
                                <SwipeItems Mode="Execute">
                                    <SwipeItem BackgroundColor="Red"
                                               Command="{Binding Source={x:Reference ListPage}, Path=BindingContext.DeleteCommand}"
                                               CommandParameter="{Binding .}"
                                               Text="Delete" />
                                </SwipeItems>
                            </SwipeView.RightItems>
                            <local:CarView
                                Padding="0,10,0,0"
                                xct:TouchEffect.Command="{Binding Source={x:Reference ListPage}, Path=BindingContext.PressedCommand}"
                                xct:TouchEffect.CommandParameter="{Binding .}"
                                xct:TouchEffect.LongPressCommand="{Binding Source={x:Reference ListPage}, Path=BindingContext.LongPressedCommand}"
                                xct:TouchEffect.LongPressCommandParameter="{Binding .}" />
                        </SwipeView>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage.Content>v

I cannot find anything related to making a horizontal listview, and I don't think is possible

0 Answers
Related