Bug 42516 - ListView ContextActions do not work on UWP
Summary: ListView ContextActions do not work on UWP
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.2.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-13 13:25 UTC by Ray Kelly
Modified: 2017-11-29 05:39 UTC (History)
11 users (show)

Tags: ac, uwp, contextaction, listview
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 42516 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Ray Kelly 2016-07-13 13:25:24 UTC
Adding context actions to a list view on UWP do not work.  Seems to work ok on all other plaforms.

              <ViewCell.ContextActions>
                <MenuItem Clicked="OnEdit" CommandParameter="{Binding .}"
                   Text="Edit" />
                <MenuItem Clicked="OnDelete" CommandParameter="{Binding .}"
                   Text="Delete" IsDestructive="True" />
              </ViewCell.ContextActions>
              <ViewCell.View>

Nothing happens when you click, long hold or swipe on a listview item.
Comment 1 fjordfnord 2016-07-19 01:30:14 UTC
I'm experiencing a similar problem with Xamarin.Forms 2.3.0.117. In my case the list context actions do show up, but only intermittently. There doesn't seem to be any sensible pattern to it. For example, in a single list some items show the context menu and some not, and this changes dynamically as I keep clicking.
Comment 2 fjordfnord 2016-07-19 02:18:02 UTC
Looks like my problem is as described here (cannot click on blank areas on list items): https://forums.xamarin.com/discussion/64053/do-listview-contextactions-work-on-uwp
Comment 3 Linn Kristin Bjørkli 2017-08-24 13:13:22 UTC
Our problem is described her
https://forums.xamarin.com/discussion/86578/couple-of-problems-with-listview-context-actions-uwp
Comment 4 Alma Jensen 2017-08-28 22:17:21 UTC
I don't know how much this will help but I can get some context actions to show on UWP, and within the same app others do not show up.  As far as I can tell a lot of it may have to deal with how complex the viewcell is.  The second one that doesn't not display is far more complex than the one that does display.

Here's one that does work for me.

    <views:ListView
        Style="{StaticResource standardListview}"
        ItemsSource="{Binding PickLines}"
        ItemClickCommand="{Binding ItemSelectedCommand}"
        HasUnevenRows="true">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ViewCell.ContextActions>
              <MenuItem 
                Command="{Binding DeleteCommand}" 
                CommandParameter="{Binding .}"
                Text="Delete" />
            </ViewCell.ContextActions>
            <StackLayout>
              <Label Text="{Binding LineName}"
                     Style="{StaticResource listviewlItem}"
                     FontSize="Medium"
                     HorizontalTextAlignment="Center"
                     Margin="6"/>
            </StackLayout>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </views:ListView>

And now here's one that doesn't work. 

<views:ListView
                    Style="{StaticResource standardListview}"
              HasUnevenRows="True"
              ItemsSource="{Binding PickLineItems}"
              SeparatorVisibility="Default">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <ViewCell.ContextActions>
                                    <MenuItem
                        Command="{Binding DeleteCommand}"
                        CommandParameter="{Binding .}"
                        Text="Delete" />
                                </ViewCell.ContextActions>
                                <StackLayout Padding="5">
                                    <StackLayout Orientation="Horizontal">
                                        <Label Text="Item" />
                                        <Label Text="{Binding ItemName}" />
                                    </StackLayout>
                                    <StackLayout Orientation="Horizontal">
                        <Label Text="Restock at: " VerticalTextAlignment="Center"/>
                        <Entry Text="{Binding RestockBalance}" MinimumWidthRequest="60" Keyboard="Numeric" Placeholder="      "/>
                      </StackLayout>
                                    <StackLayout Orientation="Horizontal">
                                        <Label Text="New* " TextColor="Green" IsVisible="{Binding IsNewLocation}"/>
                                        <Label Text="Location" />
                                        <Label Text="{Binding LocationName}" />
                                    </StackLayout>
                                    <StackLayout Orientation="Horizontal">
                                        <Button 
                          Text="Up" 
                          Command="{Binding MoveUpCommand}"
                          Image="arrowup.png"/>
                                        <Button 
                          Text="Down" 
                          Command="{Binding MoveDownCommand}"
                          Image="arrowdown.png"/>
                                        <Button Text="Delete" IsVisible="{Binding IsWindows}" Command="{Binding DeleteCommand}" CommandParameter="{Binding .}"/>
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </views:ListView>
Comment 5 Mario Kneidinger 2017-08-31 15:16:38 UTC
I have the issue described here under point one:
https://forums.xamarin.com/discussion/86578/couple-of-problems-with-listview-context-actions-uwp 

And I also have a little sample project here:
https://forums.xamarin.com/discussion/86578/couple-of-problems-with-listview-context-actions-uwp

In the UWP app, if you add items to the listview with the add button, delete it, add a new one and try to delete it again it won't get deleted, because the MenuItem still references the old, already deleted value. This happens to other items in the listview as well, if you add and delete more than one item.
Comment 6 Yuri 2017-08-31 17:03:44 UTC
For the delete (and possibly other problems) the workaround is described in my answer 
https://stackoverflow.com/questions/45941761/xamarin-forms-listview-deletion-of-items-holds-old-values/45986634#45986634
but would be nice to fix that bug
Comment 7 OBATA Akio 2017-11-22 08:55:50 UTC
Tihs bug report handling multiple issues, but one of them is same as bug 42999.
Comment 8 OBATA Akio 2017-11-29 05:39:48 UTC
For the first issue, ContextMenu will be opened with Right button release action on UWP now.