Bug 59445 - ViewCell ContextAction Disappear from the App
Summary: ViewCell ContextAction Disappear from the App
Status: RESOLVED DUPLICATE of bug 55588
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-13 10:38 UTC by Vivek Suman
Modified: 2017-09-13 14:04 UTC (History)
2 users (show)

Tags:
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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 55588

Description Vivek Suman 2017-09-13 10:38:21 UTC
ViewCell ContextAction is loaded in a ListView and working fine if you perform click on MenuItem. 
However,If you don't Click and navigate on other page and Back to Listview then it disappears and will not show on any other ListView until you kill the app and reopen.

Attached is the Sample Solution.

Step to produce:

1) Click on Open ListView 
2) Swipe Right to Left to see the context Actions. DO NOT Click on it.
3) Click Back from Navigation bar
4) Click on Open ListView

You will see that Context Action and even Swipe is not enabled.
Comment 1 Vivek Suman 2017-09-13 11:37:31 UTC
It seems Attachment is failing. I am pasting code as below:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ListViewDemo.IntractiveListView" xmlns:local="clr-namespace:ListViewDemo;assembly=ListViewDemo">
	<ContentPage.Content>
		<ListView ItemsSource="{x:Static local:IntractiveListView.items}" ItemSelected="OnSelection" ItemTapped="OnTap" IsPullToRefreshEnabled="true" Refreshing="OnRefresh">
			<ListView.ItemTemplate>
				<DataTemplate>
					<ViewCell>
						<ViewCell.ContextActions>
							<!-- CommandParameter is the command to pass to the clicked event handler. Because these are menu items, 
							not cells managed by the ListView, CommandParameter is neccesary to determine which 
							cell the context action was taken on. -->
							<MenuItem Clicked="OnMore" Text="More" CommandParameter="{Binding .}" />
							<MenuItem Clicked="OnDelete" Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" />
						</ViewCell.ContextActions>
						<StackLayout Padding="15,0">
							<Label Text="{Binding .}" />
						</StackLayout>
					</ViewCell>
				</DataTemplate>
			</ListView.ItemTemplate>
		</ListView>
	</ContentPage.Content>
</ContentPage>

Code Behind:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Xamarin.Forms;

namespace ListViewDemo
{
	public partial class IntractiveListView : ContentPage
	{
		public static ObservableCollection<string> items { get; set; }
		public IntractiveListView()
		{
			items = new ObservableCollection<string>() { "speaker", "pen", "lamp", "monitor", "bag", "book", "cap", "tote", "floss", "phone" };
			InitializeComponent();
		}

		void OnSelection(object sender, SelectedItemChangedEventArgs e)
		{
			if (e.SelectedItem == null)
			{
				return; //ItemSelected is called on deselection, which results in SelectedItem being set to null
			}
			DisplayAlert("Item Selected", e.SelectedItem.ToString(), "Ok");
			//comment out if you want to keep selections
			ListView lst = (ListView)sender;
			lst.SelectedItem = null;
		}

		void OnRefresh(object sender, EventArgs e)
		{
			var list = (ListView)sender;
			//put your refreshing logic here
			var itemList = items.Reverse().ToList();
			items.Clear();
			foreach (var s in itemList)
			{
				items.Add(s);
			}
			//make sure to end the refresh state
			list.IsRefreshing = false;
		}

		void OnTap(object sender, ItemTappedEventArgs e)
		{
			DisplayAlert("Item Tapped", e.Item.ToString(), "Ok");
		}

		void OnMore(object sender, EventArgs e)
		{
			var item = (MenuItem)sender;
			DisplayAlert("More Context Action", item.CommandParameter + " more context action", "OK");
		}

		void OnDelete(object sender, EventArgs e)
		{
			var item = (MenuItem)sender;
			items.Remove(item.CommandParameter.ToString());
		}
	}
}
Comment 2 Paul DiPietro [MSFT] 2017-09-13 14:04:59 UTC

*** This bug has been marked as a duplicate of bug 55588 ***