Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

Image button on UWP not going back to normal state

Open KarolStosik opened this issue 6 years ago • 5 comments

Description

On UWP ImageButton does not go back to Normal state when clicked. It is strange, because it works only when DisplayAlert is called from within Clicked method.

Steps to Reproduce

  1. Download https://github.com/davidortinau/TheLittleThingsPlayground
  2. Remove line 26 from file ThreeFourPage.xaml (Clicked="ImageButton_Clicked")
  3. Run the app
  4. If you click the image button, it will not go back to normal state

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE: Visual Studio: 15.9.3
  • Platform Target Frameworks:
    • UWP: 16299
  • Nuget Packages: Xamarin Forms: 3.4.0.1009999 and 3.4.0.1008975
  • Affected Devices: Desktop application

KarolStosik avatar Jan 07 '19 10:01 KarolStosik

Doesn't that have to do with the associated visual states? (https://github.com/davidortinau/TheLittleThingsPlayground/blob/master/TheLittleThingsPlayground/Views/ThreeFourPage.xaml#L30-L40)

I can't seem to reproduce it in another app. Also, when I remove the "pressed" state, things seem to go back to normal.

jfversluis avatar Jan 07 '19 13:01 jfversluis

The repository I've linked to is from official xamarin blog: https://blog.xamarin.com/xamarin-forms-3-4-0-say-hello-to-imagebutton/ so I assume it should work flawlessly. I have a reproduction in another project. It looks like removing the visual states works for UWP, but now the button does not have "pressed" look on Android. The workaround is to clean visual state list after control initialization in constructor (ThreeFourPage.xaml.cs file in this case):


if (Device.RuntimePlatform == Device.UWP)
{
    VisualStateManager.SetVisualStateGroups(ImageButtonName, new VisualStateGroupList());
}

One more hint. When there are no visual states on UWP, the pressed button shrinks fluently, but when there is a visual state attached like in the sample, the change is more rapid.

KarolStosik avatar Jan 08 '19 08:01 KarolStosik

I'm also having this issue. When using the visual states from the xamarin blog being pressed and normal, if I clicked and hold the mouse on the button it will expand and then if I move the mouse off of the button, it stays expanded and doesn't scale back to normal. It only goes back to normal after a full click.

dberroa avatar Apr 29 '19 18:04 dberroa

I'm experiencing this issue as well, but on iOS with version 4.6.0.726 of Xamarin Forms.

AlexanderMelchers avatar May 26 '20 17:05 AlexanderMelchers

I am also getting this. I have a normal button that scales when pressed.

But, I also have another state in a new group that sets a border. This is also not getting unset.

One thing I noticed is that when I click off the button, it goes back to the normal state.

Normal Pressed Released
image image image
Selected Unselected
image image

mattleibow avatar Aug 22 '20 05:08 mattleibow