protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                _shellContext.Shell.PropertyChanged -= OnShellPropertyChanged;

                if (_flyoutHeader != null)
                {
                    _flyoutHeader.MeasureInvalidated -= OnFlyoutHeaderMeasureInvalidated;
                }

                if (_appBar != null)
                {
                    _appBar.RemoveOnOffsetChangedListener(this);
                    _appBar.RemoveView(_headerView);
                }

                if (_recycler != null)
                {
                    _recycler.SetLayoutManager(null);
                    _recycler.SetAdapter(null);
                    _recycler.Dispose();
                }

                _adapter?.Dispose();
                _headerView.Dispose();
                _rootView.Dispose();
                _layoutManager?.Dispose();
                _defaultBackgroundColor?.Dispose();
                _bgImage?.Dispose();

                _flyoutHeader           = null;
                _rootView               = null;
                _headerView             = null;
                _shellContext           = null;
                _appBar                 = null;
                _recycler               = null;
                _adapter                = null;
                _defaultBackgroundColor = null;
                _layoutManager          = null;
                _bgImage                = null;
            }

            base.Dispose(disposing);
        }
        protected virtual void LoadView(IShellContext shellContext)
        {
            Profile.FrameBegin();

            var context = shellContext.AndroidContext;

            // Android designer can't load fragments or resources from layouts
            if (context.IsDesignerContext())
            {
                _rootView = new FrameLayout(context);
                return;
            }

            var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null);

            Profile.FramePartition("Find Recycler");
            _recycler = coordinator.FindViewById <RecyclerView>(Resource.Id.flyoutcontent_recycler);

            Profile.FramePartition("Find AppBar");
            _appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar);

            _rootView = coordinator as ViewGroup;

            Profile.FramePartition("Add Listener");
            _appBar.AddOnOffsetChangedListener(this);

            Profile.FramePartition("Add HeaderView");
            _actionBarHeight = (int)context.ToPixels(56);
            UpdateFlyoutHeader();

            Profile.FramePartition("Recycler.SetAdapter");
            _adapter = new ShellFlyoutRecyclerAdapter(shellContext, OnElementSelected);
            _recycler.SetClipToPadding(false);
            _recycler.SetLayoutManager(_layoutManager = new ScrollLayoutManager(context, (int)Orientation.Vertical, false));
            _recycler.SetLayoutManager(new LinearLayoutManager(context, (int)Orientation.Vertical, false));
            _recycler.SetAdapter(_adapter);

            Profile.FramePartition("Initialize BgImage");
            var metrics = context.Resources.DisplayMetrics;
            var width   = Math.Min(metrics.WidthPixels, metrics.HeightPixels);

            using (TypedValue tv = new TypedValue())
            {
                if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true))
                {
                    _actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics);
                }
            }

            width -= _actionBarHeight;

            coordinator.LayoutParameters = new LP(width, LP.MatchParent);

            _bgImage = new ImageView(context)
            {
                LayoutParameters = new LP(coordinator.LayoutParameters)
            };

            Profile.FramePartition("UpdateFlyoutHeaderBehavior");
            UpdateFlyoutHeaderBehavior();
            _shellContext.Shell.PropertyChanged += OnShellPropertyChanged;

            Profile.FramePartition("UpdateFlyoutBackground");
            UpdateFlyoutBackground();

            Profile.FramePartition(nameof(UpdateVerticalScrollMode));
            UpdateVerticalScrollMode();
            Profile.FrameEnd();
        }