我有两页MainPage和SecondPage1 .in App.xaml.cs我使用以下代码导航到Secondpage1: App.xaml.cs:
//MainPage = new Fmkt44Application.MainPage();/*First Approach*/
MainPage = new NavigationPage(new MainPage());/*Second approach*/
MainPage.xaml.cs中:
// App.Current.MainPage = new NavigationPage(new SecondPage1());/*First Approach*/
await Navigation.PushAsync(new SecondPage1());/*Second approach*/
问题是,如果我使用这两种方法,我可以导航到secondpage1,但如果我使用第二种方法,我无法写入搜索栏或任何条目。是什么原因以及如何解决?
这是MainPage.xaml.cs
namespace Fmkt44Application
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public async System.Threading.Tasks.Task LoginControlAsync(Object sender, EventArgs args)
{
User.UserName = entry_user.Text;
User.Password = entry_passw.Text;
if (User.CheckUserInformation() == false)
{
DisplayAlert("Login", "Kullanıcı Adını veya şifresini giriniz", "OK");
}
else
{
String val = entry_user.Text + "$" + entry_passw.Text;
CallIasWebService.Login();
String rval = CallIasWebService.CallIASService("PROFILECONTROL", val);
CallIasWebService.Logout();
User.Profile = rval.ToString();
if (rval != "0" )
{
if (User.Profile != "" && User.Profile != null)
{
// App.Current.MainPage = new NavigationPage(new SecondPage1());if I Call Like this I can write on Secondpage1 (First approach)
await Navigation.PushAsync(new SecondPage1());/*I cannot reach SecondPage1 controls/* (second approach)*/
}
else
{
DisplayAlert("Login", "Kayıt yapma yetkiniz yoktur.", "OK");
}
}
else
{
DisplayAlert("Login", "Kullanıcı Adını veya şifresi hatalıdır.", "OK");
}
}
}
public async System.Threading.Tasks.Task scanncontrolAsync(Object sender, EventArgs E)
{
// await Navigation.PushAsync(new SecondPage1());
App.Current.MainPage = new SecondPage1();
}
}
}
App.cs是
public App ()
{
InitializeComponent();
//MainPage = new Fmkt44Application.MainPage();(First apploach)
MainPage = new NavigationPage(new MainPage());/*second approach*/
}
Secondpage1.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="Fmkt44Application.SecondPage1">
<ContentPage.Content>
<StackLayout>
<SearchBar Placeholder="Ara..." TextChanged="TextChange" x:Name="searchbar" />
<ListView x:Name="Materials" ItemTapped="MakineSec" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<StackLayout Orientation="Horizontal" >
<Label Text="{Binding Material}"/>
<Label Text="{Binding Stext}"/>
</StackLayout>
<Entry Text="{Binding SerialNumber}" />
</StackLayout>
<ViewCell.ContextActions>
<MenuItem Text="Seç" Clicked="MakineSec" CommandParameter="{Binding .}"/>
</ViewCell.ContextActions>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
答案 0 :(得分:0)
问题来自Android模拟器。我尝试了一个真正的平板电脑问题。