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

How to 'include' NavigationPage in XAML

$
0
0

Hi,

I'm trying to make as much work as possible in XAML. Is it possible to 'include'/embed XAML with NavigationPage into another XAML?

Example - MenuPage:

        <?xml version="1.0" encoding="UTF-8"?>
        <MasterDetailPage 
            xmlns="http://xamarin.com/schemas/2014/forms" 
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
            x:Class="MyApp.MenuPage"
            xmlns:local="clr-namespace:MyApp;assembly=MyApp"
            Style="{StaticResource PageStyle}"
            Title="MyApp">

            <MasterDetailPage.Master Title="Menu">
                <local:Menu/>
            </MasterDetailPage.Master>

            <MasterDetailPage.Detail>
                <local:DashboardPage/>
            </MasterDetailPage.Detail>
        </MasterDetailPage>

and my DashboardPage looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<NavigationPage
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="MyApp.DashboardPage" 
    xmlns:local="clr-namespace:MyApp;assembly=MyApp"
    Style="{StaticResource NavigationPageStyle}">

    <x:Arguments>
        <local:UTTabbedPage Title="Dashboard" Style="{StaticResource TabbedPageStyle}">
            <local:UTTabbedPage.Children>
            <local:ObjectsPage />               
                <local:HostsPage />
                <local:ServicesPage />
            </local:UTTabbedPage.Children>
        </local:UTTabbedPage>
    </x:Arguments>
</NavigationPage>

After login page I'm loading MenuPage like this:
Application.Current.MainPage = new MenuPage();

When I copy my DashboardPage directly into MenuPage everything works as expected. But when I try to embed DashboardPage into MenuPage I have error: "NavigationPage must have a root Page before being used. Either call PushAsync with a valid Page, or pass a Page to the constructor before usage."

Any idea?


Viewing all articles
Browse latest Browse all 89864

Trending Articles



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