Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Page creation are too slow

$
0
0

Hi all !
The topic question resume the topic pretty well...
My app is for a professional use (it won't be on the store or anything), so i can handle some loading time, but in this case it's a little too much.

App structure

To describe the structure of the app.
I have a main page where i can choose a topic in a listview.
This clic open a CarousselPage and inside it I have to put X pages (between 1 and 18)
Each page need 700ms (average) to load. And obsiously... it's too long (18 * 700 = 12sec)

My "analyze"

I checked many thing but 99% of the time is used by InitializeComponent() of the page creation.
I desactivate all the binding and 10% max of the loading time (it's a little less in reality) is used by it ( All the title / button label... come from and object stored in the viewModel (already created) and the data was previously loaded from an xml file)
It's not the real issue.

After some reading, it seems my problem can come from my XAML structure ?

My code

The app look like this (those are the color for my test and the real design (margin, real color, title, logo etc...) is not totaly implemented yet, do not puke on it plz :D )
The buttons are custom toogle button (they load really (really) fast I checked it)

*i can"t post my image ... i'm too "young" to post a link :( *

Description;
In the page (landscape only), you avec 1 to 5 lines without scrolbar.

A line have a picture on the left who take all the height of the line.
on the right of this picture, the height is divide in two row (1/3 and 2/3)

The top have the "Title" on the left, and on the right we have two buttons (Comment / Photo / Helper => Open popup or camera)
The bottom have two to 5 custom toogleButtons with some binding to and object in the viewModel.

And my code look like this (i did not put all the code, i stopped after the First toogle button. The rest of the xaml is the end of the line (4 more buttons and stacklayout / grid end) then the 4 new line (same code)

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class ="TowaV4.Views. ControlPortiereAVGPage"
              xmlns="htt p://xamarin.com/schemas/2014/forms"
              xmlns:x="htt p://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:tooB="clr-namespace:TowaV4.Toggle"
              xmlns:helper="clr-namespace:TowaV4.Helper"
              xmlns:local="clr-namespace:TowaV4.MarkupExtension">
    <ContentPage.Content>
        <!--Grille pour les lignes, on bind sur la liste des parts-->
        <Grid x:Name="TopGrid"  Grid.Row="0" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="0"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="6*"/>
            </Grid.ColumnDefinitions>
            <!--Icone de la ligne-->
            <Frame Grid.Row="1" Grid.Column="0"  OutlineColor="Red" CornerRadius="5" Padding="1,1,1,1" >
                <Image Source="{local:EmbeddedImage RessourceId=TowaV4.Images.configIcon.png}"  WidthRequest="100" HeightRequest="100"></Image>
            </Frame>
            <!--Conteneur des boutons + helper + commentaire + photo-->
            <Grid 
                     Grid.Row="1" 
                     Grid.Column="1" 
                     VerticalOptions="End">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="2*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <!--Grid boutons photo/com + label-->
                <Grid 
                         Grid.Row="0" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <!--Nom de la part-->

                    <Label Grid.Column="0" Text="{Binding PartsPageToDisplay.MyParts[0].Name}"/>
                    <!--Layout des boutons supérieurs-->
                    <StackLayout       
                             Grid.Column="1" 
                             Orientation="Horizontal"
                             HorizontalOptions="EndAndExpand">
                        <!--Bouton commentaire-->
                        <Button
                                 Style="{DynamicResource ButtonPhotoControl}"
                                 TextColor="Green"
                                 Text="Comment"
                                 Command="{Binding DisplayCommentCommandClick}"
                                 CommandParameter="{ Binding PartsPageToDisplay.MyParts[0] }">
                        </Button>

                        <!--Bouton photo-->
                        <Button
                                 Style="{DynamicResource ButtonPhotoControl}"
                                 TextColor="Green"
                                 Text="Photo"
                                 Command="{Binding TakePhotoCommandClick}"
                                 CommandParameter="{ Binding PartsPageToDisplay.MyParts[0] }">
                        </Button>

                        <!--Bouton Helper-->
                        <Button
                                 Style="{DynamicResource ButtonPhotoControl}"
                                 TextColor="Green"
                                 Text="Helper"
                                 Command="{Binding DisplayHelperCommandClick}"
                                 CommandParameter="{ Binding PartsPageToDisplay.MyParts[0] }">
                        </Button>
                    </StackLayout>
                </Grid>
                <StackLayout Orientation="Horizontal"
                                  VerticalOptions="Start"
                                  Grid.Row="1" >
                    <Frame  BackgroundColor="{ Binding PartsPageToDisplay.MyParts[0].ListButtonState[0].BackgroundColor  ,Mode=TwoWay}">
                        <tooB:ToggleButton
                                 Enabled ="True"
                                 TextLabel="{ Binding PartsPageToDisplay.MyParts[0].ListButtonState[0].ButtonLabel}"
                                 Checked="{ Binding PartsPageToDisplay.MyParts[0].ListButtonState[0].IsChecked ,Mode=TwoWay}"
                                 BackgroundColor="Transparent"
                                 WidthRequest="150"
                                 HeightRequest="50" 
                                 Command="{Binding ToggleCommandClick}"
                                 CommandParameter="{ Binding PartsPageToDisplay.MyParts[0] }"
                                 />
                    </Frame>

My questions

  • Do you have an idea to help my app to go faster ?
  • Do i need to change my way of dealing with so many pages ? (First I have is to give up with carrousel, but it fill exactly what i need in term of use)
  • Do i need to improve my english ? (sorry for that, thanks for reading :blush: )

ps: last minute informations :smiley:
-I use a galaxy tab A6 10.1 to debug (it will be the production tablet)
-The Xaml is not perfectly indented, it's because it is auto-generated (by me, it's an homemade tool to create the page with the right amount of lines and buttons with the good page name etc... i have something like 80 pages with frequent modification to create so...).
-It will be use on android for the moment, but also for ios in a near future.

note for admin: I already "ask this question" a few hours ago, but I can't see the thread anywhere (forum or profile) so I just post it again. (hope it was just a bug)


Viewing all articles
Browse latest Browse all 77050

Trending Articles