void UpdateTitleView() { AToolbar bar = _toolbar; if (bar == null) { return; } Page currentPage = Element.CurrentPage; if (currentPage == null) { return; } VisualElement titleView = NavigationPage.GetTitleView(currentPage); if (_titleViewRenderer != null) { var reflectableType = _titleViewRenderer as System.Reflection.IReflectableType; var rendererType = reflectableType != null?reflectableType.GetTypeInfo().AsType() : _titleViewRenderer.GetType(); if (titleView == null || Internals.Registrar.Registered.GetHandlerTypeForObject(titleView) != rendererType) { if (_titleView != null) { _titleView.Child = null; } Platform.ClearRenderer(_titleViewRenderer.View); _titleViewRenderer.Dispose(); _titleViewRenderer = null; } } if (titleView == null) { return; } if (_titleViewRenderer != null) { _titleViewRenderer.SetElement(titleView); } else { _titleViewRenderer = Platform.CreateRenderer(titleView, Context); if (_titleView == null) { _titleView = new Container(Context); bar.AddView(_titleView); } _titleView.Child = _titleViewRenderer; } Platform.SetRenderer(titleView, _titleViewRenderer); }
void UpdateTitleView() { AToolbar bar = Toolbar; if (bar == null) { return; } Page currentPage = CurrentPage; if (currentPage == null) { return; } VisualElement titleView = NavigationPage.GetTitleView(currentPage); if (_titleViewHandler != null) { var reflectableType = _titleViewHandler as System.Reflection.IReflectableType; var rendererType = reflectableType != null?reflectableType.GetTypeInfo().AsType() : _titleViewHandler.GetType(); if (titleView == null || Internals.Registrar.Registered.GetHandlerTypeForObject(titleView) != rendererType) { if (_titleView != null) { _titleView.Child = null; } _titleViewHandler.VirtualView.Handler = null; _titleViewHandler = null; } } if (titleView == null) { return; } if (_titleViewHandler != null) { _titleViewHandler.SetVirtualView(titleView); } else { titleView.ToNative(MauiContext); _titleViewHandler = titleView.Handler; if (_titleView == null) { _titleView = new Container(NavigationLayout.Context); bar.AddView(_titleView); } _titleView.Child = (INativeViewHandler)_titleViewHandler; } }