繁体   English   中英

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

[英]Xamarin base ContentPage with loading (or common ContentViews)

如何创建一个“基本” ContentPage ,其中包含一个busy indicator (例如),并使此Page成为应用程序内其他页面的基础?

我已经尝试过以这种方式进行操作,但是没有显示busy indicator

基本页面:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
             x:Class="SgatMobileV3.Core.BasePage">
    <ContentPage.Content>
        <Grid>
            <core:VolosLoadingView />
        </Grid>
    </ContentPage.Content>
</ContentPage>

繁忙指示灯视图:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
             core:LocatorViewModel.AutoWireViewModel="true"
             x:Class="SgatMobileV3.Core.VolosLoadingView"
             xmlns:busyindicator="clr-namespace:Syncfusion.SfBusyIndicator.XForms;assembly=Syncfusion.SfBusyIndicator.XForms">

    <Grid>
     <Grid BackgroundColor="LightGray" Opacity="0.6" IsVisible="True" />
     <busyindicator:SfBusyIndicator
        IsBusy="True"
        IsVisible="True"
        x:Name="loading" AnimationType="DoubleCircle"
        ViewBoxWidth="150" ViewBoxHeight="150"
        TextColor="Green" BackgroundColor="Transparent"
        HorizontalOptions="Center" VerticalOptions="Center"/>       
     </Grid>
</ContentView>

页面:

<core:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
             core:LocatorViewModel.AutoWireViewModel="true"
             x:Class="SgatMobileV3.Views.MockPage">

    <ContentPage.Content>
        <Grid>
            <Button Text="Welcome to Xamarin.Forms! 1"
                    VerticalOptions="CenterAndExpand" 
                    HorizontalOptions="CenterAndExpand"
                    Command="{Binding Test_ClickCommand}" />
        </Grid>
    </ContentPage.Content>
</core:BasePage>

我试图在基础页面中包含一个示例label ,但是什么也没有出现。

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

如果想创建ControlTemplate在页面级别,创建ControlTemplate在应用程序级的情况下,它们也可以在页面级创建,如在下面的代码示例

<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给出一个示例

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM