Xamarin.Forms
Xamarin.Forms copied to clipboard
Image button on UWP not going back to normal state
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
- Download https://github.com/davidortinau/TheLittleThingsPlayground
- Remove line 26 from file ThreeFourPage.xaml (Clicked="ImageButton_Clicked")
- Run the app
- 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
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.
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.
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.
I'm experiencing this issue as well, but on iOS with version 4.6.0.726 of Xamarin Forms.
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 |
---|---|---|
![]() |
![]() |
![]() |
Selected | Unselected |
---|---|
![]() |
![]() |