DarkW1nter
DarkW1nter

Reputation: 2861

xamarin forms - using RaiseChild in OnAppearing

Leading on from this question I asked earlier, is it possible to have the ShowLess function run when the page opens so that the stack appears collapsed?

I tried to do it in OnAppearing but it did not work.

    protected override void OnAppearing()
        {
            bigImg.Source = ImageHelper.SetImage(Convert.ToInt32(pageIndex));
            btnClicked();
        }

        public bool isIncreased = true;
        public void btnClicked()
        {
            if(isIncreased)
            {
                ShowLess();
            }
            else
            {
                ShowMore();
            }
        }

        public void ShowLess()
        {
            articleGrid.RaiseChild(imgContainer);
            TopLayout.TranslateTo(0, -(TopLayout.Bounds.Height + 60), 500, Easing.Linear);
            isIncreased = false;
        }

        public void ShowMore()
        {
            TopLayout.TranslateTo(0, 0, 500, Easing.Linear);
            isIncreased = true;
        }

Upvotes: 0

Views: 893

Answers (1)

Michał Żołnieruk
Michał Żołnieruk

Reputation: 2105

How about setting Opacity to 0.0 in XAML for views which you don't want to see during page initialization and then (when user clicks the button) moving your "movable" views to initial position, setting opacity to 1.0 and starting the moving animation?

Upvotes: 1

Related Questions