Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug][UWP] VisualState "Disabled" not working on Button #12984

Closed
rubiomiguel06 opened this issue Nov 27, 2020 · 1 comment · Fixed by #13148
Closed

[Bug][UWP] VisualState "Disabled" not working on Button #12984

rubiomiguel06 opened this issue Nov 27, 2020 · 1 comment · Fixed by #13148
Assignees
Labels
a/button a/VSM e/1 🕐 1 in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@rubiomiguel06
Copy link

Description

From official document:

The Xamarin.Forms Visual State Manager defines one visual state group named "CommonStates" with the following visual states:
• "Normal"
• "Disabled"
• "Focused"
• "Selected"
This visual state group is supported for all classes that derive from VisualElement, which is the base class for View and Page.

For Xamarin.Forms.Button on UWP, while Normal and Focused VisualStates seem to work fine when defining their Setters (not sure what Selected would mean in a button so I didn't tested it), Disabled VisualState doesn't seem to fire up.

Steps to Reproduce

  1. Create a Custom Button like the following:
public class CustomButton : Xamarin.Forms.Button
    {
        public CustomButton()
        {
            VisualStateManager.SetVisualStateGroups(
                this,
                new VisualStateGroupList()
                {
                    new VisualStateGroup()
                    {
                        States =
                        {
                            ButtonStyle.NormalState,
                            ButtonStyle.PressedState,
                            ButtonStyle.FocusedState,
                            ButtonStyle.DisabledState
                        }
                    }
                });

        }
    }


public static class ButtonStyle
    {
        public static Color TextColor { get; } = Color.Brown;
        public static Color BackgroundColor { get; } = Color.LightBlue;
        public static double CornerRadius(double FontSize) => 0.5 * FontSize;

        public static VisualState NormalState { get; } =
            new VisualState
            {
                Name = "Normal",
                Setters =
                {
                    new Setter { Property = Button.TextColorProperty, Value = Color.Blue },
                    new Setter { Property = Button.BackgroundColorProperty, Value = Color.Gray },
                    new Setter { Property = Button.BorderColorProperty, Value = Color.Black},
                    new Setter { Property = Button.PaddingProperty, Value = new Thickness(5,0) },
                    new Setter { Property = Button.MarginProperty, Value = new Thickness(0, 0) }
                }
            };

        public static VisualState PressedState { get; } =
            new VisualState
            {
                Name = "Pressed",
                Setters =
                {
                    new Setter { Property = Button.TextColorProperty, Value = Color.Red },
                    new Setter { Property = Button.BackgroundColorProperty, Value = Color.Gray},
                    new Setter { Property = Button.BorderColorProperty, Value = Color.Black},
                    new Setter { Property = Button.PaddingProperty, Value = new Thickness(0,0) },
                    new Setter { Property = Button.MarginProperty, Value = new Thickness(5, 0) }
                }
            };

        public static VisualState FocusedState { get; } =
            new VisualState
            {
                Name = "Focused",
                Setters =
                {
                    new Setter { Property = Button.TextColorProperty, Value = Color.Green },
                    new Setter { Property = Button.BackgroundColorProperty, Value = Color.Gray },
                    new Setter { Property = Button.BorderColorProperty, Value = Color.Black },
                    new Setter { Property = Button.PaddingProperty, Value = new Thickness(5,0) },
                    new Setter { Property = Button.MarginProperty, Value = new Thickness(0, 0) }
                }
            };

        public static VisualState DisabledState { get; } =
            new VisualState
            {
                Name = "Disabled",
                Setters =
                {
                    new Setter { Property = Button.BorderColorProperty, Value = Color.Orange},
                    new Setter { Property = Button.TextColorProperty, Value = Color.Gray },
                    new Setter { Property = Button.BackgroundColorProperty, Value = Color.Blue},
                    new Setter { Property = Button.PaddingProperty, Value = new Thickness(5,0) },
                    new Setter { Property = Button.MarginProperty, Value = new Thickness(0, 0) }
                }
            };
    }
  1. Navigate through the different visual states of the button
  2. Check that Disabled state is never shown

Expected Behavior

Disabled VisualState work as Normal, Focused and Pressed states do

Actual Behavior

Disabled VisualState is never shown

Basic Information

  • Version with issue: XF 4.7.0.1260
  • Last known good version:
  • Platform Target Frameworks:
    • UWP: 18362

Environment

Microsoft Visual Studio Community 2019
Version 16.8.1
VisualStudio.16.Release/16.8.1+30711.63
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA048
Microsoft Visual C++ 2019

Azure App Service Tools v3.0.0   16.8.550.19892
Azure App Service Tools v3.0.0

C# Tools   3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

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

Extensibility Message Bus   1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   16.8.43 (00471f8)
Support for debugging Mono processes with Visual Studio.

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

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Syncfusion Xamarin Project Templates   13.4.0.53
A multi-project template for building iOS, Android, and Windows apps using Syncfusion Xamarin components.

Syncfusion Xamarin Toolbox   16.2.0.19
Syncfusion Essential Studio for Xamarin Toolbox Visual Studio extension.

SyncfusionMenu Extension   1.0
SyncfusionMenu Visual Studio Extension Detailed Info

Visual Basic Tools   3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Foo   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.8.000.255 (d16-8@d002176)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.8.0.507 (remotes/origin/d16-8@e87b24884)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.8.112 (86385a3)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   11.1.0.17 (d16-8/c0e2b8e)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: be2226b
    Java.Interop: xamarin/java.interop/d16-8@79d9533
    ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
    SQLite: xamarin/sqlite/3.32.1@1a3276b
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc


Xamarin.iOS and Xamarin.Mac SDK   14.4.1.3 (e30c41de3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
@rubiomiguel06 rubiomiguel06 added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 27, 2020
@PureWeen
Copy link
Contributor

AUWPTouchState.zip

@PureWeen PureWeen added a/VSM e/1 🕐 1 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed s/unverified New report that has yet to be verified labels Dec 11, 2020
@jsuarezruiz jsuarezruiz self-assigned this Dec 14, 2020
@jsuarezruiz jsuarezruiz added the in-progress This issue has an associated pull request that may resolve it! label Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/button a/VSM e/1 🕐 1 in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants