Bug 26322 - Container's IsEnabled property does not inherit by child button
Summary: Container's IsEnabled property does not inherit by child button
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-23 01:22 UTC by glucose1e
Modified: 2015-02-27 03:35 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description glucose1e 2015-01-23 01:22:17 UTC
Sometimes we want to disable group of controls in one container. For example, in Xamarin.Forms Android
<Grid HorizontalOptions="FillAndExpand" IsEnabled="{Binding IsOperatable}">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Button Text="Save" Grid.Column="0" Command="{Binding SaveCommand}"  />
              <Button Text="Cancle" Grid.Column="1" Command="{Binding CancelCommand}"}" />
</Grid>
If we change the IsOperatable, then all buttons in grid is enabled\disabled at the same time since the property can be inherited. This works good in WPF, but in Xamarin forms, this doesn't work. We need to do following coding:
<Grid HorizontalOptions="FillAndExpand" >
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Button Text="Save" Grid.Column="0" Command="{Binding SaveCommand}" IsEnabled="{Binding IsOperatable}" />
              <Button Text="Cancel" Grid.Column="1" Command="{Binding CancelCommand}" IsEnabled="{Binding IsOperatable}" />
            </Grid>
This is not good if there are lots of child controls.  Duplicated coding is not so wonderful. 
I wonder if this is a bug or just by design. If it is a bug, please fix it. Thanks.
Comment 1 Abhishek 2015-02-19 06:15:12 UTC
Created attachment 9919 [details]
Test Sample

I have tried this issue and able to reproduce the reported behavior at my ends.

Steps to Reproduce:
1. Create Xamarin.Forms Application (PCL).
2. Add two xaml page in the solution.Copy the above two code.
3. 1st tabbed page i.e 'Page 1' contain the second code which disable the button control individual.
4. 2nd tabbed page i.e 'Page 2' contain the first code which disable the group of controls in the container.
5. Run the application, Page 1 disable the button individually but page 2 does not disable the group of controls in the container.

Screencast: http://www.screencast.com/t/0fFkSVTjO

I have create a test sample with the help of code provided in bug description and I am attaching my test sample with bug.

@glucose1e, It would be great if you will see my test sample and will confirm that this is the correct test project to replicate your issue.

Build Info:
Xamarin.Forms: 1.3.5.6333-pre1

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.6.00007

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0446016-02589
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0446016-02589
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0446016-02589
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0446016-02589
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0446016-02589
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0446016-02589
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0446016-02589
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Compact & SQLite Toolbox   4.1.0
SQL Server Compact & SQLite Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections.

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.9.291.0 (9f3e552)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.6.1.0 (3b3ef438017c7ecf486defa9e01567a5f2b3cb2a)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified
Comment 2 Abhishek 2015-02-19 06:20:44 UTC
Android Device Log: https://gist.github.com/AkhileshKumar01/ea8cab97d20364fd77ae
Comment 3 glucose1e 2015-02-24 23:35:24 UTC
@Abhishek  Yes, the example is exactly correct. 
I'd like to suggest that add event to change the IsEnabled property to see whether the group of controls changes along with the container.  That would be wonderful.
Comment 4 Jason Smith [MSFT] 2015-02-27 03:35:45 UTC
Xamarin.Forms does not currently support inherited properties. I would suggest binding IsEnabled on your buttons to the IsEnabled of your layout using the Source paramater.

We have an open API discussion about adding property inheritance, but this is the current intended design (mostly becuase property inheritance is expensive and mobile is fairly performance sensitive already).

Note You need to log in before you can comment on or make changes to this bug.