Xamarin.forms: [Bug] Unable to get SwipeView to work

Created on 17 Jan 2020  路  7Comments  路  Source: xamarin/Xamarin.Forms

Description

In a simple CollectionView example, SwipeView is throwing an exception with Android. Haven't tried iOS.

Steps to Reproduce

  1. Download the repo (https://github.com/JohnLivermore/SampleXamarinApp/tree/swipeview)
  2. Run the repo

Expected Behavior

SwipeView works

Actual Behavior

Get an unhandled exception...

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

Basic Information

  • Version with issue: 4.4
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:

    • iOS:

    • Android:

    • UWP:

  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

image

Reproduction Link

https://github.com/JohnLivermore/SampleXamarinApp/tree/swipeview

Workaround

unverified bug

Most helpful comment

@ignacioinnovo Please read https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/experimental-flags for more about experimental flags. If you call SetFlags more than once, you are actually overwriting the value you've previously set. Instead, you should call it once with all the flags you want enabled. And @JohnLivermore is correct. CollectionView is no longer experimental. Thanks!

All 7 comments

The SwipeView is in the Preview phase (we are working to improve it). To use it, you must opt-in by calling Forms.SetFlags ("SwipeView_Experimental") before calling Forms.Init ().
issue9242
The sample with the initialization change:
Issue9242.zip

thx for the answer @jsuarezruiz

Thanks for that. I was setting the experimental flag, but not with the exact code you have. I was using ...

        global::Xamarin.Forms.Device.SetFlags(new[] { "SwipeView_Experimental" });

However, now when I run I am getting this...

image

Is this because my device is older? Here is what VS shows it to be...

image

This is working in iOS however. Just not Android (at least for my device).

Dear Xamarin Forms Team,

If I use these two sentences (in this order) inside MainActivity:

global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
global::Xamarin.Forms.Forms.SetFlags("SwipeView_Experimental");

I get an exception in Android with Xamarin Forms 4.5.0.495.

If I swap the order to this:

global::Xamarin.Forms.Forms.SetFlags("SwipeView_Experimental");
global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");

it works OK in a page where I have a CollectionView and a SwipeView.

I don't think CollectionView needs the CollectionView_Experimental any longer?

@ignacioinnovo Please read https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/experimental-flags for more about experimental flags. If you call SetFlags more than once, you are actually overwriting the value you've previously set. Instead, you should call it once with all the flags you want enabled. And @JohnLivermore is correct. CollectionView is no longer experimental. Thanks!

My mistake. I didn麓t know that.
Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings