XAM-Consulting / SlideOverKit

Easily Create Awesome Slideover's in Xamarin.Forms
Apache License 2.0
394 stars 120 forks source link

Change SlideMenu dynamically? Should work #17

Closed ghost closed 8 years ago

ghost commented 8 years ago

I want to have a different SlideMenu depending on which ToolBarItem is tapped.

Looking at the code for MenuContainerPage, the following code looks like it should work:

    public partial class LocationListPage : MenuContainerPage
    {
        #region Constructors
        public LocationListPage ()
        {
            InitializeComponent ();
        }
        #endregion Constructors

        protected override void OnAppearing ()
        {
            base.OnAppearing ();
            MessagingCenter.Subscribe<LocationListPageModel> (this, MessagingConstants.LocationsSortMenuShow, (sender) => {
                this.SlideMenu = new LocationsSortMenuView ();
                ShowMenu ();
            });
        }

        protected override void OnDisappearing ()
        {
            base.OnDisappearing ();
            MessagingCenter.Unsubscribe<LocationListPageModel> (this, MessagingConstants.MenuShow);
        }
    }

However, the menu does not show. It only works if I set this.SlideMenu in the constructor.

Any solution to this, and/or suggestions?

jessejiang0214 commented 8 years ago

Well, it cannot be add, cause of OnAppearing will be called after OnElementChanged. How about change the content in MenuView in runtime? Like set IsVisible for ViewA and un visible for ViewB