{"id":22920903,"url":"https://github.com/enusbaum/xamarinexamples.forms.movewithkeyboard","last_synced_at":"2026-05-13T13:51:34.738Z","repository":{"id":88397016,"uuid":"122132725","full_name":"enusbaum/XamarinExamples.Forms.MoveWithKeyboard","owner":"enusbaum","description":"Xamarin.Forms example of how to move Xamarin.Forms elements with the iOS soft keyboard so they're not covered up","archived":false,"fork":false,"pushed_at":"2018-02-19T23:24:27.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T08:48:41.592Z","etag":null,"topics":["xamarin","xamarin-forms","xamarin-ios","xamarin-renderers"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enusbaum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-02-19T23:15:49.000Z","updated_at":"2022-02-16T09:03:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d0890d1-8d05-44f4-a5ed-f8e092a15c3c","html_url":"https://github.com/enusbaum/XamarinExamples.Forms.MoveWithKeyboard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.MoveWithKeyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.MoveWithKeyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.MoveWithKeyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.MoveWithKeyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enusbaum","download_url":"https://codeload.github.com/enusbaum/XamarinExamples.Forms.MoveWithKeyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246651240,"owners_count":20811990,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["xamarin","xamarin-forms","xamarin-ios","xamarin-renderers"],"created_at":"2024-12-14T07:17:22.133Z","updated_at":"2026-05-13T13:51:29.708Z","avatar_url":"https://github.com/enusbaum.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XamarinExamples.Forms.MoveWithKeyboard\n\nThis repository holds an example of the best way I've been able to come up with to handle moving Xamarin.Forms elements as to not be covered by the iOS soft keyboard when it appears.\n\nI hope this is able to lend a hand to anyone else looking for a simple solution to this problem.\n\nCheers!\n\n# How it works\n\n\n### Xamarin.Forms Code\n\nIn the Xamarin.Forms project we setup a very basic Custom Renderer (in this case, but a Button element) that tracks a boolean value for \"MoveWithKeyboard\". \n\n```csharp\npublic class CustomButton : Button\n    {\n        public const string MoveWithKeyboardName = \"MoveWithKeyboard\";\n\n        public CustomButton() { }\n\n        public static readonly BindableProperty MoveWithKeyboardProperty = BindableProperty.Create(\n            propertyName: MoveWithKeyboardName,\n            returnType: typeof(bool),\n            declaringType: typeof(CustomButton),\n            defaultValue: false);\n\n        public bool MoveWithKeyboard\n        {\n            get { return (bool)GetValue(MoveWithKeyboardProperty); }\n            set { SetValue(MoveWithKeyboardProperty, value); }\n        }\n    }\n\n```\n\nThen in our XAML we use the custom renderer for the button:\n\n```xml\n\u003ccustom:CustomButton MoveWithKeyboard=\"true\" .... /\u003e\n```\n\n### Xamarin.iOS\n\nFor the Xamarin.iOS bit, we create a Custom Renderer for the Button element.\n\n([**Link**](https://github.com/enusbaum/XamarinExamples.Forms.MoveWithKeyboard/blob/c07521ed7450b622405639c4de971248da31e21e/iOS/Renderers/CustomButton_IOS.cs#L84-L132) to where the magic happens in the IOS Custom Renderer)\n\n```csharp\nprotected override void OnElementChanged(ElementChangedEventArgs\u003cButton\u003e e)\n{\n        ... setup notifications ...\n}\n```\n\nIn the **OnElementChanged** method, we setup two observers and register them with NSNotificationCenter that we register the events on both the **UIKeyboard.WillShowNotification** and **UIKeyboard.WillHideNotification** which will invoke our delegates when the keyboard is displayed and hidden.\n\n#### FYI\n\nWorth noting, there's some hackery around ensuring the Touch event is fired. It appears in Xamarin.Forms \"Touch\" really means \"TouchUp\". The issue we run into while relocating a button is that \"TouchDown\" triggers the keyboard to be hidden and thus triggering the notification event to relocate the button back to its original position. \n\nBecause the button is moved, the \"TouchUp\" event is not fired. The custom renderer in the iOS project has my workaround for this issue, which I have opened a Bugzilla case for (#[58263](https://bugzilla.xamarin.com/show_bug.cgi?id=58263)).\n\nCheers!\n\n![Example of moving button](https://d2ffutrenqvap3.cloudfront.net/items/392u180T33063c2H0f1B/Screen%20Recording%202018-02-19%20at%2005.48%20PM.gif \"Example of moving button\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.movewithkeyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.movewithkeyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.movewithkeyboard/lists"}