locked
Do ListView ContextActions work on UWP RRS feed

  • Question

  • User1278 posted

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

    Thanks!

    Tuesday, April 5, 2016 9:16 PM

Answers

  • User76916 posted

    @RaymondKelly - while I haven't tested it myself, UWP shouldn't be missing something that is available in all other platforms. I would check bugzilla.xamarin.com and submit a bug if you can't get them to work.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, April 6, 2016 3:29 AM
  • User49731 posted

    @RaymondKelly - not sure if it's the same issue as yours but I thought context actions wasn't working either but then discovered that (unlike on other platforms) they do work but seems like you have to be holding on a label (or control) within the list item for it to work, anywhere in the whitespace won't .. which is obviously a bug in itself but more specific.

    For instance I have a two-line listitem listview where each item has a label on each line and if the label is shorter than the width of screen (as often) then tapping and holding on the label itself will bring up context actions but tapping past the label in the space to the right won't .. although it is being picked up somehow as the item is highlighted.

    Example:

    "ListItem line 1 " "ListItem line 2 "

    Tapping and holding on area within "ListItem line 1" (or 2) works but tapping and holding in the spaces following doesn't

    @TheRealJasonSmith - Hi Jason, I seem to remember something similar to this problem on WP8.1 at one point and had something to do with transparency? Possibly same issue?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 11, 2016 10:55 AM
  • User89714 posted

    Sorry, late joining this thread. I am using XF 2.3.1.114, and testing on both desktop (using right click) and phone (using long press), I am not seeing issues with context actions on ListView on UWP, no matter where within the ViewCell I press. I am using a DataTemplateSelector with multiple possible templates, uneven rows, etc.

    If anyone is seeing problems on 2.3.1.114, post a small sample.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, September 13, 2016 3:48 PM

All replies

  • User76916 posted

    @RaymondKelly - while I haven't tested it myself, UWP shouldn't be missing something that is available in all other platforms. I would check bugzilla.xamarin.com and submit a bug if you can't get them to work.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, April 6, 2016 3:29 AM
  • User1278 posted

    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.

    Wednesday, April 6, 2016 1:58 PM
  • User49731 posted

    @RaymondKelly - not sure if it's the same issue as yours but I thought context actions wasn't working either but then discovered that (unlike on other platforms) they do work but seems like you have to be holding on a label (or control) within the list item for it to work, anywhere in the whitespace won't .. which is obviously a bug in itself but more specific.

    For instance I have a two-line listitem listview where each item has a label on each line and if the label is shorter than the width of screen (as often) then tapping and holding on the label itself will bring up context actions but tapping past the label in the space to the right won't .. although it is being picked up somehow as the item is highlighted.

    Example:

    "ListItem line 1 " "ListItem line 2 "

    Tapping and holding on area within "ListItem line 1" (or 2) works but tapping and holding in the spaces following doesn't

    @TheRealJasonSmith - Hi Jason, I seem to remember something similar to this problem on WP8.1 at one point and had something to do with transparency? Possibly same issue?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 11, 2016 10:55 AM
  • User1278 posted

    @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.

    Monday, April 11, 2016 6:11 PM
  • User224290 posted

    Yeah, it still not working.

    Thursday, May 19, 2016 3:16 AM
  • User14299 posted

    Using the right mouse button worked for me.

    Thursday, June 23, 2016 7:58 PM
  • User1278 posted

    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

    Wednesday, July 13, 2016 1:19 PM
  • User1278 posted

    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).

    Wednesday, July 13, 2016 2:57 PM
  • User118529 posted

    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.

    Friday, July 29, 2016 5:53 PM
  • User89714 posted

    Sorry, late joining this thread. I am using XF 2.3.1.114, and testing on both desktop (using right click) and phone (using long press), I am not seeing issues with context actions on ListView on UWP, no matter where within the ViewCell I press. I am using a DataTemplateSelector with multiple possible templates, uneven rows, etc.

    If anyone is seeing problems on 2.3.1.114, post a small sample.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, September 13, 2016 3:48 PM
  • User89714 posted

    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.

    Wednesday, October 26, 2016 5:06 PM
  • User55063 posted

    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>

    Thursday, July 13, 2017 6:47 PM
  • User251004 posted

    @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.

    Wednesday, August 2, 2017 11:28 AM
  • User1278 posted

    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.

    Saturday, August 5, 2017 12:58 PM
  • User251004 posted

    @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

    Monday, August 7, 2017 4:08 AM
  • User56560 posted

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

    Monday, April 23, 2018 9:38 AM