public static void DisposeModelAndChildrenRenderers(this VisualElement view) { IVisualElementRenderer renderer; foreach (var child in view.Descendants().OfType <VisualElement>()) { renderer = XFPlatform.GetRenderer(child); XFPlatform.SetRenderer(child, null); if (renderer == null) { continue; } renderer.NativeView.RemoveFromSuperview(); renderer.Dispose(); } renderer = XFPlatform.GetRenderer(view); if (renderer != null) { renderer.NativeView.RemoveFromSuperview(); renderer.Dispose(); } XFPlatform.SetRenderer(view, null); }
public static IVisualElementRenderer GetOrCreateRenderer(this VisualElement bindable) { var renderer = XFPlatform.GetRenderer(bindable); if (renderer == null) { renderer = XFPlatform.CreateRenderer(bindable); XFPlatform.SetRenderer(bindable, renderer); } return(renderer); }
void UpdateCell(ViewCell cell) { if (_viewCell != null) { Device.BeginInvokeOnMainThread(_viewCell.SendDisappearing); } _viewCell = cell; Device.BeginInvokeOnMainThread(_viewCell.SendAppearing); IVisualElementRenderer renderer; if (_rendererRef == null || !_rendererRef.TryGetTarget(out renderer)) { renderer = GetNewRenderer(); } else { if (renderer.Element != null && renderer == Platform.GetRenderer(renderer.Element)) { renderer.Element.ClearValue(Platform.RendererProperty); } var type = Internals.Registrar.Registered.GetHandlerType(_viewCell.View.GetType()); if (renderer.GetType() == type || (renderer is DefaultRenderer && type == null)) { renderer.SetElement(_viewCell.View); } else { //when cells are getting reused the element could be already set to another cell //so we should dispose based on the renderer and not the renderer.Element Platform.DisposeRendererAndChildren(renderer); renderer = GetNewRenderer(); } } Platform.SetRenderer(_viewCell.View, renderer); }
void PackContent() { ClearContentRenderer(); if (ScrollView.Children.Count == 0 || !(ScrollView.Children[0] is VisualElement)) { return; } var content = (VisualElement)ScrollView.Children[0]; if (Platform.GetRenderer(content) == null) { Platform.SetRenderer(content, Platform.CreateRenderer(content)); } _contentRenderer = Platform.GetRenderer(content); (ContentView as FlippedClipView).ContentRenderer = _contentRenderer; DocumentView = _contentRenderer.NativeView; ContentView.PostsBoundsChangedNotifications = true; }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { Element.PropertyChanged -= OnElementPropertyChanged; Platform.SetRenderer(Element, null); if (_appeared) { Page.SendDisappearing(); } _appeared = false; if (_events != null) { _events.Dispose(); _events = null; } if (_packager != null) { _packager.Dispose(); _packager = null; } if (_tracker != null) { _tracker.Dispose(); _tracker = null; } Element = null; _disposed = true; } base.Dispose(disposing); }
nfloat CalculateHeightForCell(NSTableView tableView, Cell cell) { var viewCell = cell as ViewCell; double renderHeight; if (List.RowHeight == -1 && viewCell?.View != null) { var target = viewCell.View; if (_prototype == null) { _prototype = Platform.CreateRenderer(target); Platform.SetRenderer(target, _prototype); } else { _prototype.SetElement(target); Platform.SetRenderer(target, _prototype); } var req = target.Measure(tableView.Frame.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); target.ClearValue(Platform.RendererProperty); foreach (var descendant in target.Descendants()) { descendant.ClearValue(Platform.RendererProperty); } renderHeight = req.Request.Height; } else { renderHeight = cell.RenderHeight; } return(renderHeight > 0 ? (nfloat)renderHeight : ListViewRenderer.DefaultRowHeight); }
void UpdateControllers() { ClearControllers(); if (Platform.GetRenderer(MasterDetailPage.Master) == null) { Platform.SetRenderer(MasterDetailPage.Master, Platform.CreateRenderer(MasterDetailPage.Master)); } if (Platform.GetRenderer(MasterDetailPage.Detail) == null) { Platform.SetRenderer(MasterDetailPage.Detail, Platform.CreateRenderer(MasterDetailPage.Detail)); } AddSplitViewItem(new NSSplitViewItem { ViewController = new ViewControllerWrapper(Platform.GetRenderer(MasterDetailPage.Master)) }); AddSplitViewItem(new NSSplitViewItem { ViewController = new ViewControllerWrapper(Platform.GetRenderer(MasterDetailPage.Detail)) }); UpdateChildrenLayout(); }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { if (Carousel != null) { Carousel.PropertyChanged -= OnPropertyChanged; Carousel.PagesChanged -= OnPagesChanged; } Platform.SetRenderer(Element, null); if (_appeared) { _appeared = false; Page?.SendDisappearing(); } if (_events != null) { _events.Dispose(); _events = null; } if (_tracker != null) { _tracker.Dispose(); _tracker = null; } Element = null; _disposed = true; } base.Dispose(disposing); }
void TeardownPage(Page page) { page.PropertyChanged -= OnPagePropertyChanged; Platform.SetRenderer(page, null); }