Skip to content

Instantly share code, notes, and snippets.

@chrisdiana
Created September 9, 2014 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdiana/04431f0c8cf75a1e90a7 to your computer and use it in GitHub Desktop.
Save chrisdiana/04431f0c8cf75a1e90a7 to your computer and use it in GitHub Desktop.
Add Done and Dismiss Keyboard for UITextView in Xamarin
// sample text box
var deedDescriptionField = new UITextView (new RectangleF (0, 230, UIScreen.MainScreen.Bounds.Width, 100)){
BackgroundColor = UIColor.White,
Text = " Description:",
TextColor = ViewHelpers.DarkGray,
Font = UIFont.FromName("Helvetica", 18f)
};
// change the return key to done
descriptionField.ReturnKeyType = UIReturnKeyType.Done;
// dismiss keyboard on done
descriptionField.ShouldChangeText = (text, range, replacementString) => {
if (replacementString.Equals ("\n")) {
deedDescriptionField.EndEditing (true);
return false;
} else {
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment