Assertion error for ViewCell.Tapped

MonkeyfeetMonkeyfeet USMember ✭✭
edited January 2018 in Xamarin.Forms

I'm getting a weird error for what feel like should be something straightforward. I have a ListView with a DataTemplate shown below. For some reason when I run this, and tap on a cell, it closes immediately with

Assertion at [Long Path]/xamarin-android/external/mono/mono/metadata/marshal.c:7928, condition `mono_method_signature (method)->pinvoke' not met

in the Output.
The XAML in question:

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell x:Name="_vcellBlock"
                              Tapped="_vcellBlock_Clicked">
                        <StackLayout x:Name="_stkCellBlock"
                                     Orientation="Horizontal">

                            <StackLayout Orientation="Vertical"
                                         HorizontalOptions="StartAndExpand">
                                <Label Text="{Binding Name}"
                                       FontSize="Medium"/>
                                <Label Text="{Binding Description}"/>
                            </StackLayout>

                            <Frame
                                WidthRequest="75"
                                Padding="0"
                                HorizontalOptions="End">
                                <Label x:Name="_lblListQty"
                                       Text="{Binding QuantityToString}"
                                       HorizontalOptions="Center"
                                       VerticalOptions="Center"
                                       FontSize="Large"
                                   />
                            </Frame>

                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

_vcellBlock_Clicked is defined, but it doesn't seem to matter since break points put on the function are never hit. The assertion is killing it before the event handler ever gets called.

Edit: Other event handlers works fine (like those in the toolbar).

Additional edit: Swapping the event out for an ItemTappedEvent attached to the ListView "solves" the problem in the sense that it no longer fails the assertion. I'd still like to know why though.

Answers

  • MonkeyfeetMonkeyfeet USMember ✭✭

    In case it's relevant, this is the basic function:

        protected async void _vcellBlock_Clicked(object sender, EventArgs e)
        {
            ViewCell tappedCell = (ViewCell)sender;
            var itemData = (ViewModelData)((ListView)tappedCell.Parent).SelectedItem;
    
            ...Giant if statement for navigating to another page...
        }
    
Sign In or Register to comment.