Xamarin基本ContentPage带有加载(或常见的ContentViews)

时间:2019-02-01 10:45:25

标签: c# xaml xamarin xamarin.forms content-pages

我如何创建一个包含示例的None的“基础” request.session.get('is_login', False) ,并将其False用作应用程序内其他页面的基础?

我尝试过这种方式,但是未显示None

基本页面:

ContentPage

忙碌指示器视图:

busy indicator

页面:

Page

我试图在基础页面中包含示例busy indicator,但什么也没有出现。

2 个答案:

答案 0 :(得分:1)

  

我如何创建一个“基本” ContentPage,其中包含一个繁忙指示器(例如),并将此页面作为其他页面的基础

如果要在页面级别创建ControlTemplate,在应用程序级别创建ControlTemplate实例,也可以在页面级别创建它们,如following code example所示:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SimpleTheme.HomePage">
    <ContentPage.Resources>
        <ResourceDictionary>
            <ControlTemplate x:Key="TealTemplate">
                ...
            </ControlTemplate>
            <ControlTemplate x:Key="AquaTemplate">
                ...
            </ControlTemplate>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentView ... ControlTemplate="{StaticResource TealTemplate}">
        ...
    </ContentView>
</ContentPage>

在页面级别添加ControlTemplate时,会将ResourceDictionary添加到ContentPage , and then the ControlTemplate`实例中,该实例包含在ResourceDictionary中。

并且还可以使用code,例如doc中有a sample

答案 1 :(得分:0)

您可以在代码(在BasePage.cs文件中)中添加控件,我认为这没有XAML解决方案。