【发布时间】:2021-05-08 22:29:22
【问题描述】:
我有一个我无法理解的问题,我想从 MainPage 导航到另一个页面 (CheckPage),然后我想回到 MainPage,程序上它可以工作,但是当顶部有一个空白时我回到MainPage,看截图
主页代码
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="xamrinApp.MainPage">
<StackLayout>
<Grid BackgroundColor="DimGray" HeightRequest="100">
<Label Text="Xamarin App" FontSize="22" Margin="0,50,0,0" HorizontalTextAlignment="Center" TextColor="White"/>
</Grid>
<Label Text="Welcome to Xamarin application" FontSize="Title" Padding="30,10,30,10"/>
<Label Text="Please select from the list:" FontSize="16" Padding="30,0,30,0"/>
<Entry x:Name="enRegistrationNumber" Margin="10"></Entry>
<Button x:Name="btnClickMe" Text="Fetch" Clicked="btnClickMe_Clicked" />
<Label x:Name="laResult" Text="..." HorizontalTextAlignment="Center"></Label>
<Button x:Name="btnCheckRecord" Text="Check Record" Clicked="btnCheckRecord_Clicked"/>
</StackLayout>
查看录制按钮代码
App.Current.MainPage = new NavigationPage(new CheckRecordPage());
CheckRecord 页面代码
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="xamrinApp.Views.CheckRecordPage">
<Grid BackgroundColor="LightYellow">
<Button x:Name="btnBack" Text="Back" Clicked="btnBack_Clicked"></Button>
</Grid>
返回按钮代码
App.Current.MainPage = new NavigationPage(new MainPage());
【问题讨论】:
标签: c# xaml xamarin xamarin.forms