summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/EditorRenderer.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/EditorRenderer.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/EditorRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/EditorRenderer.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs b/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
index d6236871..7c4acfba 100644
--- a/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
@@ -22,10 +22,10 @@ namespace Xamarin.Forms.Platform.WinRT
{
var textBox = new TextBox { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap };
+ SetNativeControl(textBox);
+
textBox.TextChanged += OnNativeTextChanged;
textBox.LostFocus += OnLostFocus;
-
- SetNativeControl(textBox);
}
UpdateText();
@@ -37,6 +37,17 @@ namespace Xamarin.Forms.Platform.WinRT
base.OnElementChanged(e);
}
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && Control != null)
+ {
+ Control.TextChanged -= OnNativeTextChanged;
+ Control.LostFocus -= OnLostFocus;
+ }
+
+ base.Dispose(disposing);
+ }
+
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == Editor.TextColorProperty.PropertyName)
@@ -65,12 +76,12 @@ namespace Xamarin.Forms.Platform.WinRT
void OnLostFocus(object sender, RoutedEventArgs e)
{
- Element?.SendCompleted();
+ Element.SendCompleted();
}
void OnNativeTextChanged(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs args)
{
- Element?.SetValueCore(Editor.TextProperty, Control.Text);
+ Element.SetValueCore(Editor.TextProperty, Control.Text);
}
void UpdateFont()