protected override void OnDetached() { try { _thisSwitch.CheckedChange -= MySwitch_CheckedChange; _thisSwitch = null; } catch { } }
protected override void OnAttached() { try { _thisSwitch = Control as global::Android.Support.V7.Widget.SwitchCompat; if (_thisSwitch != null) { ChangeColor(); _thisSwitch.CheckedChange += MySwitch_CheckedChange; } } catch (Exception ex) { Logger.WriteError(ex); } }