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

Set Content with ContentPage

$
0
0

Let's say I have the following ContentPage:

public class HomePage : ContentPage
{
    View _tabsView;
    RelativeLayout relativeLayout;
    PageViewModel viewModel;

    public HomePage()
    {
        viewModel = new PageViewModel();
        BindingContext = viewModel;

        relativeLayout = new RelativeLayout 
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand
        };

        var pages = CreatePages();

        _tabs = CreateTabs();

        var tabsHeight = 50;
        relativeLayout.Children.Add (_tabsView,
            Constraint.Constant (0),
            Constraint.RelativeToParent ((parent) => { return parent.Height - tabsHeight; }),
            Constraint.RelativeToParent (parent => parent.Width),
            Constraint.Constant (tabsHeight)
        );

        relativeLayout.Children.Add (pages,
            Constraint.RelativeToParent ((parent) => { return parent.X; }),
            Constraint.RelativeToParent ((parent) => { return parent.Y; }),
            Constraint.RelativeToParent ((parent) => { return parent.Width; }),
            Constraint.RelativeToView (_tabs, (parent, sibling) => { return parent.Height - (sibling.Height); })
        );

        Content = relativeLayout;
    }
}

Rather than set Content to be a view is there a way to set Content to be another ContentPage?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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