Bug 60045 - ListView with RecycleElement strategy doesn't handle CanExecute of TextCell Command properly (Forms->iOS)
Summary: ListView with RecycleElement strategy doesn't handle CanExecute of TextCell C...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-08 19:44 UTC by psybu3
Modified: 2018-02-15 17:53 UTC (History)
4 users (show)

Tags: recycleelement, canexecute, ac, fr
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 FIXED

Description psybu3 2017-10-08 19:44:35 UTC
Commands with CanExecute == false will gray out TextCells correctly, but leave them clickable if CachingStrategy == RecycleElement.

Tested on iOS.

example xaml:

<?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="RecycleElementBug.MainPage"
             x:Name="This"
             BindingContext="{x:Reference This}">

    <ListView CachingStrategy="RecycleElement" ItemsSource="{Binding Items}" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <TextCell Text="CanExecute is always false for me" Command="{Binding Action}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage>


using Xamarin.Forms;

namespace RecycleElementBug
{
    public partial class MainPage : ContentPage
    {
        public object Items { get; set; }

        public MainPage()
        {
            Items = new[]
            {
                new { Action = new Command(async () => await DisplayAlert("The impossible has happened", "Should be always disabled", "Ok"), () => false) }
            };

            InitializeComponent();
        }
    }
}
Comment 1 Samantha Houts [MSFT] 2018-02-07 18:22:06 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1827
Comment 2 Rui Marinho 2018-02-15 11:07:45 UTC
Should be fixed on 2.6.0
Comment 3 Samantha Houts [MSFT] 2018-02-15 17:53:36 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1889