Maui binding problem

Lloyd Sheen 1,481 Reputation points
2022-10-06T21:53:11.823+00:00

Situation: Have a list of item in a ListView. Click on item and details load into the following:

<VerticalStackLayout >  
      
    <Border Margin="0,5,0,10"  
        Padding="16,8"  
        Background="#2B0B98"  
        HorizontalOptions="Center"  
        Stroke="#C49B33"  
        StrokeThickness="4"  
        VerticalOptions="Start">  
        <Border.StrokeShape>  
            <RoundRectangle CornerRadius="20,0,0,20" />  
        </Border.StrokeShape>  
        <Label  
            FontAttributes="Bold"  
            FontSize="16"  
            Text="{Binding theGameDescription}"  
            TextColor="White" />  
    </Border>  

    <Label Text="{Binding officials.Count}" TextColor="Red"></Label>  
    <Label Text="{Binding officials[0]}"></Label>  
    <Label Text="Officials" FontSize="16" FontAttributes="Bold" TextDecorations="Underline" Margin="0,0,0,5"></Label>  
    <ListView ItemsSource="{Binding officials}" Margin="0,0,0,5" RowHeight="20"></ListView>  

    <Label Text="{Binding decisions.Count}" TextColor="Red"></Label>  
    <Label Text="{Binding decisions[0].fullName}"></Label>  
    <Label Text="Decisions" FontSize="16" FontAttributes="Bold" TextDecorations="Underline" Margin="0,0,0,5"></Label>  
      
    <ListView ItemsSource="{Binding decisions}" Margin="0,0,0,5" RowHeight="20">  
        <ListView.ItemTemplate>  
            <DataTemplate >  
                <ViewCell>  
                    <HorizontalStackLayout>  
                        <Label Text="{Binding decisionType}" Margin="0,0,10,0" FontAttributes="Bold" FontSize="16"></Label>  
                        <Label Text="{Binding fullName}" FontSize="14"></Label>  
                    </HorizontalStackLayout>  
                </ViewCell>  
            </DataTemplate>  
        </ListView.ItemTemplate>  
    </ListView>  
</VerticalStackLayout>  

Now when I click the first item in the list all the above Bindings work correctly. When I click another item the items in the two ListViews do not show.

I add the Label showing the counts of both ItemsSources of the Listviews and they change as I select another item.
I then added the Lable showing the first item of the ItemsSource and it shows.

A breakpoint property get is called on the first list click but after that it goes away. Now since the simple <Label shows the information for the 1st item of each list I have no idea why the ListViews stop working.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,712 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.