summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-04-19 00:49:13 -0600
committerJason Smith <jason.smith@xamarin.com>2016-04-18 23:49:13 -0700
commitcae3b1a53aa1108cd2ffc07d368b633b52e7d8de (patch)
treee6c17ff6f42c5a5b879521214a3697ef6f19bf22 /Xamarin.Forms.Platform.WinRT/EntryRenderer.cs
parent5f762bdc25d7d38ce751d33baa1072868ed8061d (diff)
downloadxamarin-forms-cae3b1a53aa1108cd2ffc07d368b633b52e7d8de.tar.gz
xamarin-forms-cae3b1a53aa1108cd2ffc07d368b633b52e7d8de.tar.bz2
xamarin-forms-cae3b1a53aa1108cd2ffc07d368b633b52e7d8de.zip
[UWP] Unhook Entry and Editor event handlers during Dispose (#114)
* [UWP] Null-check Element in native event handlers for Entry * Unhook event handlers in Dispose * Prevent race condition using Control in event handlers
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/EntryRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/EntryRenderer.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs b/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs
index f02abe3c..1a9fa767 100644
--- a/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs
@@ -27,10 +27,11 @@ namespace Xamarin.Forms.Platform.WinRT
if (Control == null)
{
var textBox = new FormsTextBox { Style = Windows.UI.Xaml.Application.Current.Resources["FormsTextBoxStyle"] as Windows.UI.Xaml.Style };
+
+ SetNativeControl(textBox);
textBox.TextChanged += OnNativeTextChanged;
textBox.KeyUp += TextBoxOnKeyUp;
- SetNativeControl(textBox);
}
UpdateIsPassword();
@@ -44,6 +45,17 @@ namespace Xamarin.Forms.Platform.WinRT
}
}
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && Control != null)
+ {
+ Control.TextChanged -= OnNativeTextChanged;
+ Control.KeyUp -= TextBoxOnKeyUp;
+ }
+
+ base.Dispose(disposing);
+ }
+
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
@@ -107,7 +119,7 @@ namespace Xamarin.Forms.Platform.WinRT
void TextBoxOnKeyUp(object sender, KeyRoutedEventArgs args)
{
- if (args.Key != VirtualKey.Enter)
+ if (args?.Key != VirtualKey.Enter)
return;
Element.SendCompleted();