Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Sequence contains no elements" error

Im getting the error "Sequence contains no elements" in a simple xaml form. I am fairly new to Xamarin forms so please bear with me.

Any thoughts?

<?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="CRM.Views.CustomerItem" Title="Customer Info">

<ContentPage.Content>

    <StackLayout Padding="10" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label Text="Name" Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center"></Label>
            <Entry Text="{Binding CustName}" Grid.Row="0" Grid.Column="1"/>
            <Label Text="Surname" Grid.Row="1" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center"></Label>
            <Entry Text="{Binding CustSurname}" Grid.Row="1" Grid.Column="1"/>
            <Label Text="Address" Grid.Row="2" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center"></Label>
            <Entry Text="{Binding Address}" Grid.Row="2" Grid.Column="1"/>
            <Label Text="PhoneNumber" Grid.Row="3" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center"></Label>
            <Entry Text="{Binding PhoneNumber}" Grid.Row="3" Grid.Column="1"/>
        </Grid>
    </StackLayout>

    <Button Text="Save" HorizontalOptions="FillAndExpand" BackgroundColor="Blue" TextColor="White" Clicked="Save_Clicked"></Button>
    <Button Text="Cancel" HorizontalOptions="FillAndExpand" BackgroundColor="Red" TextColor="White" Clicked="Cancel_Clicked"></Button>

</ContentPage.Content>

like image 624
user292565 Avatar asked Jun 10 '26 23:06

user292565


1 Answers

Always make sure ContentPage.Content has only one layout control like StackLayout or Grid etc and all other controls inside them.

<ContentPage.Content>
   <StackLayout>
       <!-- all controls go here -->
   </StackLayout>
</ContentPage.Content>

That will fix the problem

like image 120
Pooran Avatar answered Jun 13 '26 13:06

Pooran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!