작업이 실행 중일 때 오버레이의 내용을 표시하는 데 문제가 있습니다. 나는 매우 간단한 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
버튼)은 보이지 않습니다. 내가 True
에 overlay
의 IsVisible
속성을 설정 XAML을 변경하는 경우 :
<ContentView x:Name="overlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All"
IsVisible="True" BackgroundColor="#C0808080" Padding="10, 0">
내가 응용 프로그램을 실행 한 후 나는 큰 hideOverlayButton
버튼으로 회색 레이어를 볼 수 있습니다. 이 경우 오버레이를 숨기고 다시 표시하고 숨기거나 표시하고 숨길 수 있습니다.
처음에는 ContentView
의 내용을 볼 수 있어야합니다 ... 어떻게 해결할 수 있습니까? 문제?
답변 해 주셔서 감사합니다. 나는 기본 Xamarin.Forms 라이브러리 (이전 버전)로 작업하고 있었다. 이제 오버레이의 콘텐츠가 표시됩니다. 고맙습니다! – Jon
도와 드릴 수있어서 기쁩니다. –