A
A
Artyom Sedinin2022-04-10 15:54:02
C++ / C#
Artyom Sedinin, 2022-04-10 15:54:02

Why does space appear at the top of the xamarin form, even though I did not write it?

6252e90ba9bde126999083.png

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WindyBox1.InputPage">
    <ContentPage.Content>
        <StackLayout BackgroundColor="#2051fb">
            <Label Text="WindyBox"
                   FontSize="15"/>
            <CollectionView ItemsSource="{Binding Coolers}"
                            SelectionMode="Single"
                            BackgroundColor="#4fa1fb"
                            SelectionChanged="SelectChanged">
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid Padding="10"
                              RowDefinitions="Auto, *"
                              ColumnDefinitions="Auto, *">
                            <Image Source="Cooler.png"
                                   WidthRequest="80"
                                   HeightRequest="80"
                                   Grid.RowSpan="2"
                                   Grid.Row="0"
                                   Grid.Column="0"/>
                            <Label Text="{Binding Name}"
                                   Grid.Row="0"
                                   Grid.Column="1"/>
                            <Label Text="{Binding Condition}"
                                   Grid.Row="1"
                                   Grid.Column="1"/>
                        </Grid>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>
            <Button Text="Подключиться к устройству"
                    x:Name="ConnectDeviceButton"
                    IsEnabled="False"
                    Clicked="ConnectDeviceButton_Clicked"/>
        </StackLayout>
    </ContentPage.Content>

There appears space on top of all content.
Even if he puts a button on top of all this or something else , it is all the same .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Sedinin, 2022-04-13
@YaKotikTvoy

In general, I found a solution, all due to the fact that there we placed the page in the navigation page.
It is necessary to write in the page:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WindyBox1.InputPage"
             NavigationPage.HasNavigationBar="false">

as I understand it, navigation pages by default add an element at the top to go back, but here it didn’t appear, but it took up space, so it needs to be removed, with this code: NavigationPage.HasNavigationBar="false"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question