{"id":20918174,"url":"https://github.com/ieuanwalker/xamarin.forms.statebutton","last_synced_at":"2026-02-26T20:01:16.629Z","repository":{"id":38111692,"uuid":"360214968","full_name":"IeuanWalker/Xamarin.Forms.StateButton","owner":"IeuanWalker","description":"With this control, you are able to create any style of button. This is possible as it acts as a wrapper to your XAML and provides you the events/ commands and properties to bind to.","archived":false,"fork":false,"pushed_at":"2024-10-18T06:26:56.000Z","size":24269,"stargazers_count":13,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-24T07:47:07.653Z","etag":null,"topics":["button","control","custom","navigation","nuget","ui","ui-component","user-interface","ux","xamarin","xamarin-forms"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IeuanWalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"IeuanWalker"}},"created_at":"2021-04-21T15:14:50.000Z","updated_at":"2025-02-25T16:25:01.000Z","dependencies_parsed_at":"2024-01-08T01:44:42.337Z","dependency_job_id":"a1f86933-647a-417f-88af-a9f706be23d3","html_url":"https://github.com/IeuanWalker/Xamarin.Forms.StateButton","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/IeuanWalker/Xamarin.Forms.StateButton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.StateButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.StateButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.StateButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.StateButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IeuanWalker","download_url":"https://codeload.github.com/IeuanWalker/Xamarin.Forms.StateButton/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.StateButton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29870370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T18:42:30.764Z","status":"ssl_error","status_checked_at":"2026-02-26T18:41:47.936Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["button","control","custom","navigation","nuget","ui","ui-component","user-interface","ux","xamarin","xamarin-forms"],"created_at":"2024-11-18T16:38:01.867Z","updated_at":"2026-02-26T20:01:16.593Z","avatar_url":"https://github.com/IeuanWalker.png","language":"C#","funding_links":["https://github.com/sponsors/IeuanWalker"],"categories":[],"sub_categories":[],"readme":"| :warning:        | This NuGet/ repo is now in maintenance mode and support will end once xamarin.forms is no longer supported. _Bug fixes only._ \u003c/br\u003e MAUI repo - https://github.com/IeuanWalker/Maui.StateButton  |\n|---------------|:------------------------|\n\n# Xamarin.Forms.StateButton  [![Nuget](https://img.shields.io/nuget/v/IeuanWalker.StateButton)](https://www.nuget.org/packages/IeuanWalker.StateButton) [![Nuget](https://img.shields.io/nuget/dt/IeuanWalker.StateButton)](https://www.nuget.org/packages/IeuanWalker.StateButton) \n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.StateButton.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.StateButton?ref=badge_shield)\n\nWith this control you are able to create any style of button.\nThis is possible as it acts as a wrapper to your XAML and provides you the events/ commands and properties to bind too.\n\n## How to use it?\nInstall the [NuGet package](https://www.nuget.org/packages/IeuanWalker.StateButton) into your shared project project\n```\nInstall-Package IeuanWalker.StateButton\n```\n\nFor iOS the control needs to be initialised in you `AppDelegate.cs` before `Forms.Init();`\n```csharp\nusing StateButton.iOS;\n.............\nStateButtonRenderer.Init();\n```\n\n## What can I do with it?\n### Properties\n| Property | What it does | Extra info |\n|---|---|---- |\n| State | This changes based on the button state. i.e. `Pressed`, `NotPressed` | Default state is `NotPressed` \u003cbr/\u003e  \u003cbr/\u003e The binding mode is `OneWayToSource` so it can only be controlled via this control. |\n\n### Events\n| Event | What it does |\n|---|---|\n| Clicked | Triggerd when the button is pressed and released |\n| Pressed | Triggerd when the button is pressed |\n| Released | Triggerd when the button is released |\n\n### Commands\n| Command | What it does |\n|---|---|\n| ClickedCommand | Triggerd when the button is pressed and released |\n| PressedCommand | Triggerd when the button is pressed |\n| ReleasedCommand | Triggerd when the button is released |\n\n\n## How to style the button for different states\nThere are 2 ways to style the button -\n- [DataTriggers](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/triggers#data-triggers)\n- [VisualStateManager](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual-state-manager) _(not recommended)_\n\n### DataTriggers\nSimply add a DataTrigger to any element and bind it to the `State` property of the button - \n```xaml\n\u003cstateButton:StateButton HorizontalOptions=\"Center\"\u003e\n    \u003cstateButton:StateButton.Content\u003e\n        \u003cFrame Padding=\"20,10\" BackgroundColor=\"Red\"\u003e\n            \u003cFrame.Triggers\u003e\n                \u003cDataTrigger Binding=\"{Binding Source={RelativeSource AncestorType={x:Type stateButton:StateButton}}, Path=State}\"\n                             TargetType=\"Frame\"\n                             Value=\"Pressed\"\u003e\n                    \u003cSetter Property=\"BackgroundColor\" Value=\"LightGray\" /\u003e\n                \u003c/DataTrigger\u003e\n            \u003c/Frame.Triggers\u003e\n            \u003cLabel Text=\"Test\" TextColor=\"White\"\u003e\n                \u003cLabel.Triggers\u003e\n                    \u003cDataTrigger Binding=\"{Binding Source={RelativeSource AncestorType={x:Type stateButton:StateButton}}, Path=State}\"\n                                 TargetType=\"Label\"\n                                 Value=\"Pressed\"\u003e\n                        \u003cSetter Property=\"TextColor\" Value=\"Blue\" /\u003e\n                    \u003c/DataTrigger\u003e\n                \u003c/Label.Triggers\u003e\n            \u003c/Label\u003e\n        \u003c/Frame\u003e\n    \u003c/stateButton:StateButton.Content\u003e\n\u003c/stateButton:StateButton\u003e\n```\n\n\n### VisualStateManager\nYou can also use the VisualStateManager, but this is \u003cstrong\u003eNOT RECOMENDED\u003c/strong\u003e due to a bug in Xamarin.forms that causes a `NullReferenceException` when `TargetName` property is used, heres a link to the bug - https://github.com/xamarin/Xamarin.Forms/issues/10710.\nIf you still want to use it -\n```xaml\n\u003cstateButton:StateButton BackgroundColor=\"Red\" HorizontalOptions=\"Center\"\u003e\n    \u003cstateButton:StateButton.Content\u003e\n        \u003cFrame Padding=\"20,10\" BackgroundColor=\"Transparent\"\u003e\n            \u003cLabel Text=\"Test\" TextColor=\"White\" /\u003e\n        \u003c/Frame\u003e\n    \u003c/stateButton:StateButton.Content\u003e\n    \u003cVisualStateManager.VisualStateGroups\u003e\n        \u003cVisualStateGroup Name=\"ButtonStates\"\u003e\n            \u003cVisualState Name=\"Pressed\"\u003e\n                \u003cVisualState.Setters\u003e\n                    \u003cSetter Property=\"BackgroundColor\" Value=\"Blue\" /\u003e\n                \u003c/VisualState.Setters\u003e\n            \u003c/VisualState\u003e\n            \u003cVisualState Name=\"NotPressed\"\u003e\n                \u003cVisualState.Setters\u003e\n                    \u003cSetter Property=\"BackgroundColor\" Value=\"Red\" /\u003e\n                \u003c/VisualState.Setters\u003e\n            \u003c/VisualState\u003e\n        \u003c/VisualStateGroup\u003e\n    \u003c/VisualStateManager.VisualStateGroups\u003e\n\u003c/stateButton:StateButton\u003e\n```\n\n## Examples\n| Designs from a production app | Complex example |\n|------|------|\n|![Production example of control](/Docs/prodExample.gif)| \u003cp\u003eThis shows the StateButton as the wrapper for a card. When the card is pressed or clicked then the title is set to bold and the border goes darker.\u003c/p\u003e \u003cp\u003e The card also shakes when clicked, this shows that it works with the [AnimationBehaviours from XamarinCommunityToolkit](https://github.com/xamarin/XamarinCommunityToolkit). \u003c/p\u003e\u003cp\u003e It also shows that it works with nested TapGestureRecognizer, XF native button and nested StateButton - \u003c/p\u003e ![Complex example of control](/Docs/ComplexExample.gif)|\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.StateButton.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.StateButton?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieuanwalker%2Fxamarin.forms.statebutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fieuanwalker%2Fxamarin.forms.statebutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieuanwalker%2Fxamarin.forms.statebutton/lists"}