2016-09-08 2 views
1

작업이 실행 중일 때 오버레이의 내용을 표시하는 데 문제가 있습니다. 나는 매우 간단한 Xamarin을 만들었습니다.이 문제를 재현하는 양식 공유 프로젝트 (현재로서는 Android 에뮬레이터에서만 실행 중입니다). Button (표시하는 오버레이)과 StackLayout 다른 Button (숨길 수있는 오버레이)와 ContentView :ContentView의 콘텐츠가 시작 부분에 표시되지 않는 경우 표시되지 않습니다.

OverlayPage.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="OverlayTest.Pages.OverlayPage"> 
    <AbsoluteLayout> 
    <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All"> 
     <Button x:Name="showOverlayButton" Text="Show overlay" Clicked="ShowOverlayButtonClicked"/> 
    </StackLayout> 
    <ContentView x:Name="overlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" 
       IsVisible="False" BackgroundColor="#C0808080" Padding="10, 0"> 
     <Button x:Name="hideOverlayButton" Text="Hide overlay" Clicked="HideOverlayButtonClicked"/> 
    </ContentView> 
    </AbsoluteLayout> 
</ContentPage> 

OverlayPage 나는 2 개 메인 페이지의 요소가 있습니다. xaml.cs :

using System; 
using Xamarin.Forms; 

namespace OverlayTest.Pages 
{ 
    public partial class OverlayPage : ContentPage 
    { 
     public OverlayPage() 
     { 
      InitializeComponent(); 
     } 

     private void ShowOverlayButtonClicked(object sender, EventArgs e) 
     { 
      this.overlay.IsVisible = true; 
     } 

     private void HideOverlayButtonClicked(object sender, EventArgs e) 
     { 
      this.overlay.IsVisible = false; 
     } 
    } 
} 

App.cs :

using OverlayTest.Pages; 
using Xamarin.Forms; 

namespace OverlayTest 
{ 
    public class App : Application 
    { 
     public App() 
     { 
      // The root page of your application 
      this.MainPage = new NavigationPage(new OverlayPage()); 
     } 
    } 
} 

앱을 실행할 때 showOverlayButton을 클릭하면 회색 레이어가 표시되지만 내용 (hideOverlayButton 버튼)은 보이지 않습니다. 내가 TrueoverlayIsVisible 속성을 설정 XAML을 변경하는 경우 :

<ContentView x:Name="overlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" 
      IsVisible="True" BackgroundColor="#C0808080" Padding="10, 0"> 

내가 응용 프로그램을 실행 한 후 나는 큰 hideOverlayButton 버튼으로 회색 레이어를 볼 수 있습니다. 이 경우 오버레이를 숨기고 다시 표시하고 숨기거나 표시하고 숨길 수 있습니다.

처음에는 ContentView의 내용을 볼 수 있어야합니다 ... 어떻게 해결할 수 있습니까? 문제?

답변

1

I 해결책을 작성하고 명시한대로 정확하게 페이지를 추가했습니다. 그리고 문제없이 잘 작동했습니다. 앱은 숨겨진 오버레이로 시작되었고 오버 클릭의 콘텐츠가 표시되었고 예상대로 표시/숨기기를 할 수있었습니다.

당신을위한 나의 추천이 해결 문제 이전에 있었기 때문에 당신이 Xamarin.Forms의 최신 버전이 있는지 확인하는 것입니다

Visibility issue with dynamic content of a ContentView

링크 내가 v2.3.1.114

을 사용하는 버전을 볼 귀하의 업데이트를 알려주십시오.

+0

답변 해 주셔서 감사합니다. 나는 기본 Xamarin.Forms 라이브러리 (이전 버전)로 작업하고 있었다. 이제 오버레이의 콘텐츠가 표시됩니다. 고맙습니다! – Jon

+0

도와 드릴 수있어서 기쁩니다. –

관련 문제