Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear friends,
why button is not visible, simply adding a button control to page.

What I have tried:

XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MobilePrice.MainPage">

    
<Button Text="hello sir how are you"
        BackgroundColor="White"
        SemanticProperties.Description="hello sir how are you"/>
    
    
        <ListView ItemsSource="{Binding Names}" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid Padding="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding ImageUrl}"
                               SemanticProperties.Description="{Binding ImageUrl}"
                                                          Grid.Column="0"/>
                        <Label Text="{Binding FirstName}"
                               SemanticProperties.Description="{Binding FirstName}"
                                                          Grid.Column="0"/>
                        <Label Text="{Binding LastName}"
                               SemanticProperties.Description="{Binding LastName}"
                               Grid.Column="1"
                               Padding="10,0"/>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage>
Posted
Updated 15-Jun-23 19:55pm

1 solution

h
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MobilePrice.MainPage">

    <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

        <Button Text="hello sir how are you"
        SemanticProperties.Description="hello sir how are you"
                HorizontalOptions="Center"
                                Clicked="OnButton_Clicked" />
        <!--</ContentPage>-->

        <ListView ItemsSource="{Binding Names}" HorizontalOptions="Center">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid Padding="10">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Image Source="{Binding ImageUrl}"
                               SemanticProperties.Description="{Binding ImageUrl}"
                                                          Grid.Column="0"/>
                            <Label Text="{Binding FirstName}"
                               SemanticProperties.Description="{Binding FirstName}"
                                                          Grid.Column="0"/>
                            <Label Text="{Binding LastName}"
                               SemanticProperties.Description="{Binding LastName}"
                               Grid.Column="1"
                               Padding="10,0"/>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </VerticalStackLayout>
</ContentPage>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900