https://github.com/xamarin/xamarin-forms-samples/releases/download/113494/Xamarin_Forms___SwipeView.zip
It first worked fine (Xamarin.forms 4.4.0.991265)
But when I update Xamarin.Forms to _4.5.0.396_.
The app _crash_ when navigating to the page which contains SwipeView. (except SwipeViewCustomItemPage)
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
Then I tried a simple demo.
MainPage.xaml
<StackLayout>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Text="Favorite"
BackgroundColor="LightGreen"
Invoked="SwipeItem_Invoked"/>
<SwipeItem Text="Delete"
BackgroundColor="LightPink"
Invoked="SwipeItem_Invoked"/>
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>
</StackLayout>
MainPage.xaml.cs
private void SwipeItem_Invoked(object sender, EventArgs e)
{
Debug.WriteLine("SwipeItem_Invoked");
}
The app crash at MainPage.xaml.g.cs
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(MainPage));
}// Here
System.InvalidCastException: 'Specified cast is not valid.'
But It work fine using SwipeItemView
<StackLayout>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Text="123"/>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>
</StackLayout>
don't crash
just don't crash
app crash
Sorry, Forget to delete <SwipeItem Text="123"/>
using SwipeItemView
<StackLayout>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
<SwipeItemView>
<Label Text="123"/>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>
</StackLayout>
Still exists in latest preview
I have the same problem
Still exists in latest preview
My fault. Issue for me wasthat i have set Forms.SetFlags twice and so the SwipeView_Experimental was overwritten.
Could you try with Xamarin.Forms 4.5.0.495?. Attached a sample with your code.
Issue10057.zip
had the same issue
the version 4.5.0.495 solved it! thanks a lot
the version 4.5.0.495 solved it
I have 4.5.0.657 and tried using the same code as in the example with SwipeItems and SwipeItemView and it still crashes with Exception thrown by target of invocation. Am using an emulated Nexus 4 and Android 10.