{"id":38281,"date":"2018-11-15T14:17:28","date_gmt":"2018-11-15T19:17:28","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=38281"},"modified":"2019-03-25T13:50:38","modified_gmt":"2019-03-25T21:50:38","slug":"xamarin-forms-3-4-0-say-hello-to-imagebutton","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-forms-3-4-0-say-hello-to-imagebutton\/","title":{"rendered":"Xamarin.Forms 3.4.0: Say Hello to ImageButton"},"content":{"rendered":"<p>As part of our long-term goal to have more frequent releases, we\u2019re pleased to announce the release of Xamarin.Forms 3.4.0. As always, this release contains even more bug fixes and most notably, another new highly requested feature, an ImageButton!<\/p>\n<h3>ImageButton<\/h3>\n<p>The <a href=\"https:\/\/github.com\/xamarin\/\/pull\/1974\">ImageButton<\/a>\u00a0is a new control which is functionally separate from a typical Button where the Image property is usually for displaying a small icon next to the Button\u2019s text. Implementing the button is straightforward, as you might expect:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;ImageButton Source=\"xamagon.png\" \r\n            BackgroundColor=\"Transparent\"\r\n            WidthRequest=\"300\"\r\n            HeightRequest=\"300\"\r\n            FlexLayout.AlignSelf=\"Center\"\r\n            FlexLayout.Grow=\"1\"\r\n            Clicked=\"ImageButton_Clicked\"\r\n            Aspect=\"AspectFit\"&gt;\r\n    &lt;VisualStateManager.VisualStateGroups&gt;\r\n        &lt;VisualStateGroup x:Name=\"CommonStates\"&gt;\r\n            &lt;VisualState x:Name=\"Normal\"&gt;\r\n                &lt;VisualState.Setters&gt;\r\n                    &lt;Setter Property=\"Scale\" Value=\"1\"\/&gt;\r\n                &lt;\/VisualState.Setters&gt;\r\n            &lt;\/VisualState&gt;\r\n\r\n            &lt;VisualState x:Name=\"Pressed\"&gt;\r\n                &lt;VisualState.Setters&gt;\r\n                    &lt;Setter Property=\"Scale\" Value=\"0.8\"\/&gt;\r\n                &lt;\/VisualState.Setters&gt;\r\n            &lt;\/VisualState&gt;\r\n\r\n        &lt;\/VisualStateGroup&gt;\r\n    &lt;\/VisualStateManager.VisualStateGroups&gt;\r\n&lt;\/ImageButton&gt;<\/pre>\n<p>In the above example, you set an image in the same way as on an Image using the Source property which takes any <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/images?tabs=windows\">ImageSource<\/a>, and you can now add a handler for the <code>Clicked<\/code> event. Using the <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/visual-state-manager\">VisualStateManager<\/a> introduced in Xamarin.Forms 3.0, you can do things such as change the scale of the button when pressed. The result:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/imagebutton-1.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-38300 size-full\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/imagebutton-1.gif\" alt=\"\" width=\"608\" height=\"1080\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><code>ImageButton<\/code> also supports <code>Command<\/code> and <code>CommandParameter<\/code> for easily binding to a ViewModel or other binding context.<\/p>\n<div class=\"mceTemp\"><\/div>\n<h3>Get Started Today!<\/h3>\n<p>Check out the full <a href=\"https:\/\/developer.xamarin.com\/releases\/xamarin-forms\/xamarin-forms-3.4\/\">release notes<\/a> for all of the details and we encourage you to explore the documentation. Xamarin.Forms 3.4.0 includes more than 40 bug fixes and ships less than a month after 3.3.0, giving you more improvements at an even quicker pace.<\/p>\n<p>This update is now available on NuGet via the Visual Studio package manager. The new <code>ImageButton<\/code> control can also be seen in action in\u00a0<em>The Little Things Playground.<\/em><\/p>\n<ul>\n<li><a href=\"https:\/\/www.nuget.org\/packages\/Xamarin.Forms\/\">NuGet<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/davidortinau\/TheLittleThingsPlayground\">The Little Things Playground<\/a><\/li>\n<\/ul>\n<p><strong>Find a new issue or have a suggestion?<\/strong><\/p>\n<p>We invite everyone to engage with us on GitHub to <a href=\"https:\/\/github.com\/xamarin\/\/issues\/new\">report any new issues or make suggestions<\/a>.<\/p>\n<p>To find out what we are working on right now, explore our sprint project boards on GitHub. Finally, if you\u2019re curious about what comes next and want to help us shape Xamarin.Forms, visit the <a href=\"https:\/\/aka.ms\/xfroadmap\">Xamarin.Forms Feature Roadmap<\/a> and let us know what you think!<\/p>\n<p><a href=\"https:\/\/forums.xamarin.com\/\"><em>Discuss this post in the Xamarin forums.<\/em><\/a>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of our long-term goal to have more frequent releases, we\u2019re pleased to announce the release of Xamarin.Forms 3.4.0. As always, this release contains even more bug fixes and most notably, another new highly requested feature, an ImageButton!<\/p>\n","protected":false},"author":1958,"featured_media":40934,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,367],"tags":[810,409,16],"class_list":["post-38281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","category-xamarin-forms","tag-imagebutton","tag-releases","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>As part of our long-term goal to have more frequent releases, we\u2019re pleased to announce the release of Xamarin.Forms 3.4.0. As always, this release contains even more bug fixes and most notably, another new highly requested feature, an ImageButton!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/38281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/1958"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=38281"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/38281\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/40934"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=38281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=38281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=38281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}