Do ListView ContextActions work on UWP

RaymondKellyRaymondKelly USMember ✭✭✭

It does not seem like context actions work in UWP projects. Is that an accurate statement? Works fine on all other platforms.

Thanks!

Best Answers

Answers

  • RaymondKellyRaymondKelly USMember ✭✭✭

    I have not found anything on bugzilla and confirmed that it just doesnt work. Long hold and swipe do nothing. I will have to log a new bug I guess. Thanks.

  • RaymondKellyRaymondKelly USMember ✭✭✭

    @DerekPapworth.4183 thank you for the suggestion, however that did not work either. I tried clicking all over the ViewCell and no context actions. I even unhooked ItemSelected to make sure that was not interfering.

  • ykurniawanykurniawan USUniversity

    Yeah, it still not working.

  • DonMcQueenyDonMcQueeny USMember

    Using the right mouse button worked for me.

  • RaymondKellyRaymondKelly USMember ✭✭✭

    Seems like its still broke. Does not work with click, long hold, swipe, right click. ContextActions just do not work on UWP. I have logged a bug https://bugzilla.xamarin.com/show_bug.cgi?id=42516

  • RaymondKellyRaymondKelly USMember ✭✭✭

    Actually it was a combination of other issues. @DerekPapworth.4183 was on the right track. It was a combination of issues rending the view cell, most of which was the fact UnEvenRows does not render properly on UWP (ARGGGGG again).

  • BrianOBrienBrianOBrien USUniversity

    This is definitely wonky behavior; one way to make the problem appear is to add and remove items from a bound ObservableCollection. Items already in the collection when the ListView is initially created do bind correctly, but after I delete and add items to the ObservableCollection in the app, some of the added items do not bind correctly.

  • JohnHardmanJohnHardman GBUniversity mod
    edited October 2016

    One thing to be aware of, which is currently undocumented (I have a bug logged, number 44773, to get the documentation and code updated to match on this) - even when using ListViewCachingStrategy.RetainElement, on UWP there is virtualisation happening as if you were actually using ListViewCachingStrategy.RecycleElement. IMHO, this may have implications for how you interact with ListView (I have been told it should make no difference, but I beg to differ).

    I have just been putting together a repro sample for one ListView bug (43832), and although I haven't finished that one yet, I've just found what looks like another ListView bug on UWP, where changes I make to the contents of a ViewCell (which works on Android, and works on iOS with a slight hiccup about needing the cell refreshed, fails dismally on UWP). I would be happier with ListView on UWP, if the RetainElement strategy actually did what it said, so that code using ListView can initially be built with a deterministic layer underneath, rather than having unpredictable virtualisation going on immediately, and then change to RecycleElement once the basics are in place.

  • MarkTaparauskasMarkTaparauskas USXamarin Team, University, XamUProfessors Xamurai

    The whole cell might not be receiving events - try putting your content in a panel with a background color. For example, adding the Transparent background color to the StackPanel below allows the entire ViewCell to react to a long press on UWP:

    <ListView>
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout BackgroundColor="Transparent"> <--- note the color setting here
                        <Label ... />
                        <Label ... />
                    </StackLayout>
                    <ViewCell.ContextActions>
                        <MenuItem Text="..." Clicked="..." />
                    </ViewCell.ContextActions>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
    
  • SmeSme USMember ✭✭✭

    @MarkTaparauskas said:
    The whole cell might not be receiving events - try putting your content in a panel with a background color. For example, adding the Transparent background color to the StackPanel below allows the entire ViewCell to react to a long press on UWP:

    Thanks, that did the trick; simply adding BackgroundColor = Color.Transparent to the grid containing the 'cell layout' enables the whole cell to react to context actions.

  • RaymondKellyRaymondKelly USMember ✭✭✭

    This may be a misunderstanding on how context actions work on UWP. Context actions are fired with right click, NOT a long hold. I am unsure what the documentation suggests but somehow I fell into trying long hold at some point. Right click context actions seems to work well across the whole view cell using latest XF Pre-6 release.

  • SmeSme USMember ✭✭✭

    @RaymondKelly said:
    This may be a misunderstanding on how context actions work on UWP. Context actions are fired with right click, NOT a long hold. I am unsure what the documentation suggests but somehow I fell into trying long hold at some point. Right click context actions seems to work well across the whole view cell using latest XF Pre-6 release.

    I'm using 2.3.4.247, and it still wasn't working with right click until I added the transparent background

  • jp.6089jp.6089 USMember ✭✭

    Adding the BackgroundColor="Transparent" to the stacklayout fixed it for me! Should be in the docs of the contextactions.

Sign In or Register to comment.