protected override void Dispose(bool disposing) { if (disposing) { if (_flyoutContainer != null) { _flyoutContainer.Dispose(); _flyoutContainer = null; } if (_detailContainer != null) { _detailContainer.Dispose(); _detailContainer = null; } if (Element != null) { Element.Appearing -= OnFlyoutPageAppearing; Element.Disappearing -= OnFlyoutPageDisappearing; } } base.Dispose(disposing); }
protected override void OnElementChanged(ElementChangedEventArgs <FlyoutPage> e) { if (_flyoutPage == null) { _flyoutPage = new Native.FlyoutPage(Forms.NativeParent) { IsPresented = e.NewElement.IsPresented, Flyout = _flyoutContainer = new FlyoutContainer(Element, true), Detail = _detailContainer = new FlyoutContainer(Element, false), }; _flyoutPage.IsPresentedChanged += (sender, ev) => { Element.IsPresented = ev.IsPresent; }; _flyoutPage.UpdateIsPresentChangeable += (sender, ev) => { (Element as IFlyoutPageController).CanChangeIsPresented = ev.CanChange; }; SetNativeView(_flyoutPage); } if (e.OldElement != null) { (e.OldElement as IFlyoutPageController).BackButtonPressed -= OnBackButtonPressed; e.OldElement.Appearing -= OnFlyoutPageAppearing; e.OldElement.Disappearing -= OnFlyoutPageDisappearing; } if (e.NewElement != null) { (e.NewElement as IFlyoutPageController).BackButtonPressed += OnBackButtonPressed; e.NewElement.Appearing += OnFlyoutPageAppearing; e.NewElement.Disappearing += OnFlyoutPageDisappearing; } UpdateFlyoutLayoutBehavior(); base.OnElementChanged(e); }
/// <summary> /// Handles a basic <see cref="MessageBoxMessage" /> on a flyout container by showing a <see cref="ModernMessageBox" /> /// and invokes the callback. /// </summary> /// <param name="message">The message.</param> /// <param name="owner">The owner.</param> /// <exception cref="System.ArgumentNullException">owner</exception> public static void HandleWithModern(this MessageBoxMessage message, FlyoutContainer owner) { if (owner == null) { throw new ArgumentNullException("owner"); } var d = owner.FindDispatcher(); if (d != null && !d.CheckAccess()) { d.BeginInvoke(new Action <Window>(win => { HandleWithModern(message, win); }), owner); return; } var res = ModernMessageBox.Show(owner, message.Content, message.Caption, message.Button, message.Icon, message.DefaultResult); message.DoCallback(res); }