summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-06-16 13:51:16 -0400
committerRui Marinho <me@ruimarinho.net>2016-06-16 18:51:16 +0100
commitd44396a4534b1e2bc81143c809e4adaee656ab15 (patch)
tree7e98b02e4052b32e4a12d153a973131aa6918053 /Xamarin.Forms.Platform.Android/Renderers
parentaf6ac9649f71d1557dffa3dc3357868016ebc1e7 (diff)
downloadxamarin-forms-d44396a4534b1e2bc81143c809e4adaee656ab15.tar.gz
xamarin-forms-d44396a4534b1e2bc81143c809e4adaee656ab15.tar.bz2
xamarin-forms-d44396a4534b1e2bc81143c809e4adaee656ab15.zip
[Android] DatePicker unfocuses on cancel (#204)
The DatePicker in Android would remain focused when being closed via the cancel button, and a subsequent re-focus via something such as button would not function as expected.
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
index 5b0e0994..328336ff 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
@@ -31,6 +31,7 @@ namespace Xamarin.Forms.Platform.Android
_disposed = true;
if (_dialog != null)
{
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog.Hide();
_dialog.Dispose();
_dialog = null;
@@ -84,6 +85,7 @@ namespace Xamarin.Forms.Platform.Android
_dialog.Hide();
((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog = null;
}
}
@@ -96,6 +98,8 @@ namespace Xamarin.Forms.Platform.Android
view.Date = e.Date;
((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
+
+ _dialog.CancelEvent -= OnCancelButtonClicked;
_dialog = null;
}, year, month, day);
}
@@ -123,9 +127,16 @@ namespace Xamarin.Forms.Platform.Android
UpdateMinimumDate();
UpdateMaximumDate();
+
+ _dialog.CancelEvent += OnCancelButtonClicked;
_dialog.Show();
}
+ void OnCancelButtonClicked(object sender, EventArgs e)
+ {
+ Element.Unfocus();
+ }
+
void SetDate(DateTime date)
{
Control.Text = date.ToString(Element.Format);