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

ListView with bound source doesnt work in more complex xaml

$
0
0

Hi,

I encourage weird problem today. I have simple listview with 2 properties bound.
It works like a charm when my Xaml looks like this:

<StackLayout>    
    <ListView x:Name="mylist"
                ItemTapped="ItemTapped_Click"
          ItemsSource="{Binding item}">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <Grid HorizontalOptions="CenterAndExpand">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="9*" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
              </Grid.RowDefinitions>
              <Label Grid.Row="0"
                        Grid.Column="0"
                        Text="{Binding prop1}" TextColor="White" />
              <Label Grid.Row="1"
                        Grid.Column="0"
                        Text="{Binding prop2}" TextColor="White"/>
              <Image Grid.RowSpan="2"
                     Grid.Column="1"
                     Source="image.png" />
            </Grid>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </StackLayout>

It works. Some item is clicked, and everything is fine.
I wanted to add the same listview to another xaml page which is more complex. Syntax is fine, but when item is clicked there is:
System.NullReferenceException: Object reference not set to an instance of an object
and its very confusing for me because debugger stopped on OnPropertyChanged handler.
Everything works, except when I put this listview to another layout.

Regards


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>