2017-08-11 42 views
1

我试图在Xamarin Forms上显示加载页时遇到问题。加载页面显示正确,但是当我设置ContentView.IsVisible = false应该查看的StackLayout不可见。谁能帮我这个?。这是XAML代码和后台代码:当ContentView不可见时出现空白页

<?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(); 
    } 

回答

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> 
:我做了以下的固定情况
相关问题