protected override void OnElementChanged(ElementChangedEventArgs <MasterDetailPage> e) { if (_mdpage == null) { _mdpage = new Native.MasterDetailPage(Forms.Context.MainWindow) { Master = GetNativePage(e.NewElement.Master), Detail = GetNativePage(e.NewElement.Detail), IsPresented = e.NewElement.IsPresented, }; _mdpage.IsPresentedChanged += (sender, ev) => { Element.IsPresented = _mdpage.IsPresented; }; _mdpage.UpdateIsPresentChangeable += (sender, ev) => { (Element as IMasterDetailPageController).CanChangeIsPresented = ev.CanChange; }; SetNativeView(_mdpage); } if (e.OldElement != null) { (e.OldElement as IMasterDetailPageController).BackButtonPressed -= OnBackButtonPressed; } if (e.NewElement != null) { (e.NewElement as IMasterDetailPageController).BackButtonPressed += OnBackButtonPressed; } UpdateMasterBehavior(); base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <MasterDetailPage> e) { if (_mdpage == null) { _mdpage = new Native.MasterDetailPage(Forms.NativeParent) { IsPresented = e.NewElement.IsPresented, Master = _masterContainer = new MasterDetailContainer(Element, true), Detail = _detailContainer = new MasterDetailContainer(Element, false), }; _mdpage.IsPresentedChanged += (sender, ev) => { Element.IsPresented = ev.IsPresent; }; _mdpage.UpdateIsPresentChangeable += (sender, ev) => { (Element as IMasterDetailPageController).CanChangeIsPresented = ev.CanChange; }; SetNativeView(_mdpage); } if (e.OldElement != null) { (e.OldElement as IMasterDetailPageController).BackButtonPressed -= OnBackButtonPressed; e.OldElement.Appearing -= OnMasterDetailAppearing; e.OldElement.Disappearing -= OnMasterDetailDisappearing; } if (e.NewElement != null) { (e.NewElement as IMasterDetailPageController).BackButtonPressed += OnBackButtonPressed; e.NewElement.Appearing += OnMasterDetailAppearing; e.NewElement.Disappearing += OnMasterDetailDisappearing; } UpdateMasterBehavior(); base.OnElementChanged(e); }