【问题标题】:Blank page when ContentView is not visibleContentView 不可见时的空白页
【发布时间】:2017-08-12 04:24:46
【问题描述】:

我在尝试在 Xamarin Forms 上显示加载页面时遇到问题。加载页面显示得恰到好处,但是当我设置 ContentView.IsVisible = false 时,应该查看的 StackLayout 不可见。谁能帮我这个?。这是 XAML 代码和背后的代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MobileAccessControl.Views.ConfigurarLectora">
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Guardar" Clicked="ToolbarItem_Clicked" />
    </ContentPage.ToolbarItems>
    <ScrollView>
        <StackLayout x:Name="slPrincipal" VerticalOptions="Center" HorizontalOptions="Center">
            <StackLayout Padding="20,20,20,20" VerticalOptions="Center" HorizontalOptions="Center">
                <Image Source="danger.jpg" HeightRequest="50" WidthRequest="50"/>
            </StackLayout>
            <StackLayout VerticalOptions="Center" HorizontalOptions="Center">
                <Picker x:Name="pckPanel" 
                        ItemsSource="{Binding ListaPaneles}" 
                        ItemDisplayBinding="{Binding Name}" 
                        Title="Panel" 
                        SelectedIndexChanged="pckPanel_SelectedIndexChanged"
                        WidthRequest="360"/>
                <Picker x:Name="pckLectoraEntrada" 
                        ItemsSource="{Binding ListaLectoras}" 
                        ItemDisplayBinding="{Binding Name}" 
                        Title="Lectora de Entrada" 
                        SelectedIndexChanged="pckLectora_SelectedIndexChanged" 
                        WidthRequest="360"/>
                <Picker x:Name="pckLectoraSalida" 
                        ItemsSource="{Binding ListaLectoras}" 
                        ItemDisplayBinding="{Binding Name}" 
                        Title="Lectora de Salida" 
                        SelectedIndexChanged="pckLectoraSalida_SelectedIndexChanged" />
            </StackLayout>
        </StackLayout>
        <ContentView x:Name="LoadingOverlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1"  AbsoluteLayout.LayoutFlags="All" IsVisible="True" BackgroundColor="#C0808080" Padding="10, 0">
            <ActivityIndicator  WidthRequest="110" HeightRequest="70" IsRunning="True" IsVisible="True" Color="DarkGray" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
        </ContentView>
    </ScrollView>
</ContentPage>

CS:

    protected async override void OnAppearing()
    {
        if (await _conf.GetListaPaneles())
        {
            LoadingOverlay.IsVisible = false;
        }

        base.OnAppearing();
    }

【问题讨论】:

    标签: c# xamarin xamarin.forms


    【解决方案1】:

    我的错。如果 ContentView 不在 AbsoluteLayout 内,我似乎无法完成。我通过执行以下操作解决了这种情况:

    <ScrollView>
            <AbsoluteLayout>
                <StackLayout x:Name="slPrincipal" VerticalOptions="Center" HorizontalOptions="Center">
                    <StackLayout Padding="20,20,20,20" VerticalOptions="Center" HorizontalOptions="Center">
                        <Image Source="danger.jpg" HeightRequest="50" WidthRequest="50"/>
                        <Label Text="Ingrese los datos del panel y lectora asociados a la tablet en Lenel OnGuard. Se deberá elegir un panel virtual exclusivo para Tablets. IMPORTANTE: No seleccione un panel real con lectoras en linea. Se pueden generar problemas en la base de datos."/>
                    </StackLayout>
                    <StackLayout VerticalOptions="Center" HorizontalOptions="Center">
                        <Picker x:Name="pckPanel" 
                                ItemsSource="{Binding ListaPaneles}" 
                                ItemDisplayBinding="{Binding Name}" 
                                Title="Panel" 
                                SelectedIndexChanged="pckPanel_SelectedIndexChanged"
                                WidthRequest="360"/>
                        <Picker x:Name="pckLectoraEntrada" 
                                ItemsSource="{Binding ListaLectoras}" 
                                ItemDisplayBinding="{Binding Name}" 
                                Title="Lectora de Entrada" 
                                SelectedIndexChanged="pckLectora_SelectedIndexChanged" 
                                WidthRequest="360"/>
                        <Picker x:Name="pckLectoraSalida" 
                                ItemsSource="{Binding ListaLectoras}" 
                                ItemDisplayBinding="{Binding Name}" 
                                Title="Lectora de Salida" 
                                SelectedIndexChanged="pckLectoraSalida_SelectedIndexChanged" />
                    </StackLayout>
                </StackLayout>
                <ContentView x:Name="LoadingOverlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1"  AbsoluteLayout.LayoutFlags="All" IsVisible="True" BackgroundColor="#C0808080" Padding="10, 0">
                    <ActivityIndicator  WidthRequest="110" HeightRequest="70" IsRunning="True" IsVisible="True" Color="DarkGray" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
                </ContentView>
            </AbsoluteLayout>
        </ScrollView>
    

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 1970-01-01
      • 2017-05-02
      • 2021-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多