Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to add View on all the pages using base page?

$
0
0

Hello Folks,

I would like to add a simple stack layout with height 50 to the bottom of all the pages of app.
Like, I need to show a progress indicator with the percentage in this view when user trying to sync the data.

On my side, I have BasePage and all the pages are extending from this page.
I tried below code for doing this.

BasePage.cs

            public void AddSyncview()
            {
                var syncView = new StackLayout();
                syncView.HorizontalOptions = LayoutOptions.FillAndExpand;
                syncView.VerticalOptions = LayoutOptions.FillAndExpand;
                syncView.BackgroundColor = Color.SeaGreen;

                var boxView = new BoxView();
                boxView.BackgroundColor = Color.Teal;
                boxView.HeightRequest = 30;
                boxView.HorizontalOptions = LayoutOptions.FillAndExpand;
                boxView.VerticalOptions = LayoutOptions.EndAndExpand;

                syncView.Children.Add(Content);
                syncView.Children.Add(boxView);
                this.Content = syncView;
            }

I thought the "Content" is pointing to the current page of content. So, I can take top stack layout and bind that content in that stacklayout.
so, I can call this method on BasePage OnAppearing and will get it working.

But actually, its not working.
This is replacing the current page content with "syncView"...


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>