[Shell] expose CurrentShell (#4626) fixes #4625
authorStephane Delcroix <stephane@delcroix.org>
Fri, 7 Dec 2018 00:53:50 +0000 (01:53 +0100)
committerRui Marinho <me@ruimarinho.net>
Fri, 7 Dec 2018 00:53:50 +0000 (00:53 +0000)
* [Shell] expose CurrentShell

- fixes #4625

* Update Xamarin.Forms.Core/Shell/Shell.cs

Co-Authored-By: hartez <hartez@users.noreply.github.com>
Xamarin.Forms.Core/Shell/Shell.cs

index 1c3c28f..e2d8b48 100644 (file)
@@ -162,8 +162,6 @@ namespace Xamarin.Forms
 
                static readonly BindablePropertyKey MenuItemsPropertyKey =
                        BindableProperty.CreateReadOnly(nameof(MenuItems), typeof(MenuItemCollection), typeof(Shell), null, defaultValueCreator: bo => new MenuItemCollection());
-                       
-#region IShellController
 
                List<(IAppearanceObserver Observer, Element Pivot)> _appearanceObservers = new List<(IAppearanceObserver Observer, Element Pivot)>();
                List<IFlyoutBehaviorObserver> _flyoutBehaviorObservers = new List<IFlyoutBehaviorObserver>();
@@ -324,9 +322,7 @@ namespace Xamarin.Forms
                        OnNavigated(new ShellNavigatedEventArgs(oldState, CurrentState, source));
                }
 
-#endregion IShellController
-
-#region URI Navigation
+               public static Shell CurrentShell => Application.Current?.MainPage as Shell;
 
                public async Task GoToAsync(ShellNavigationState state, bool animate = true)
                {
@@ -484,8 +480,6 @@ namespace Xamarin.Forms
                        return stateBuilder.ToString();
                }
 
-#endregion URI Navigation
-
                public static readonly BindableProperty CurrentItemProperty =
                        BindableProperty.Create(nameof(CurrentItem), typeof(ShellItem), typeof(Shell), null, BindingMode.TwoWay,
                                propertyChanging: OnCurrentItemChanging,
@@ -1009,4 +1003,4 @@ namespace Xamarin.Forms
                }
                #endregion
        }
-}
\ No newline at end of file
+}