question

BMartin-4607 avatar image
0 Votes"
BMartin-4607 asked LeonLu-MSFT commented

Why is my ContentViewCommand Crashing app in Xamarin Forms UWP?

This happens in UWP, but not in Android. I have note checked iOS.

It also only happens with a collectionview... not a listview.

I want to click on a collectionview item and have a different ContentView pop up.

Here's the strange part.... It works just fine if I have a DisplayActionSheet in it, but not without. The actionsheet doesn't even have to do anything.

 private async Task ExecuteSavedTripDetailsPageCommand(object selection)
         {
             if (selection == null)
             {
                 return;
             }
    
             SelectedSavedTrip = selection as Trip;
    
             selection = null;
    
             var results = await Application.Current.MainPage.DisplayActionSheet("What Would You Like To Do?", "Cancel",
                 null, "Go To Item", "Delete Item", "Delete All");
    
             SavedTripsCV = new TripDetailsCV();
    
         }

But the minute I comment it out, I get :

Xamarin.Forms.Platform.UWP
SelectableItemsViewRenderer`1.UpdateFormsSingleSelection ()
Xamarin.Forms.Platform.UWP
SelectableItemsViewRenderer`1.UpdateFormsSelection ()
Windows.ApplicationModel.Core
UnhandledError.Propagate ()
Microsoft.AppCenter.Utils
ApplicationLifecycleHelper.<ctor>b__17_1 (Object sender, UnhandledErrorDetectedEventArgs eventArgs)




dotnet-xamarinwindows-uwp
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is ExecuteSavedTripDetailsPageCommand related to the Collectionview's SelectionChangedCommand or the command in the ContentView?

I put the ExecuteSavedTripDetailsPageCommand in the Collectionview's SelectionChangedCommand, remove the DisplayActionSheet or add it, both of them are worked as normal in UWP.

My Xamarin.Forms version is 5.0.0.2012

0 Votes 0 ·

Thanks, @LeonLu-MSFT , but that's where it's at.


   <CollectionView
             x:Name="SavedTripsCollectionView"
             Grid.Row="1"
             Margin="0"
             HorizontalOptions="Center"
             ItemsSource="{Binding SavedTripsCollection}"
             SelectionChangedCommand="{Binding SavedTripDetailsPageCommand}"
             SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference SavedTripsCollectionView}}"
             SelectionMode="Single"
             WidthRequest="600">


0 Votes 0 ·

Could you share code about pop up ContentView? And your SavedTripDetailsPageCommand just popup ContentView, am I right?

0 Votes 0 ·

Here's the command and method. I don't know how to show xaml in this forum. It always tells be I don't have permission.

private ICommand savedTripDetailsPageCommand;
public ICommand SavedTripDetailsPageCommand =>
savedTripDetailsPageCommand ??
(savedTripDetailsPageCommand = new Command<object>(async (x) => await ExecuteSavedTripDetailsPageCommand(x)));

 private async Task ExecuteSavedTripDetailsPageCommand(object selection)
 {
     if (selection == null)
     {
         return;
     }

     SelectedSavedTrip = selection as Trip;

     selection = null;


     SavedTripsCV = new TripDetailsCV();

 }
0 Votes 0 ·

I test your ExecuteSavedTripDetailsPageCommand code in my demo, I remove or add DisplayActionSheet, both of them are running normally, that is so weird, could you share a demo about it.

97168-image.png


0 Votes 0 ·
image.png (203.1 KiB)

0 Answers