0
我有一個名爲HomePage的文件,名爲HomePage,它接受用戶的eURL內容。如何打開一個網頁,點擊一個按鈕在xamarin表格中
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace zaposta_angelar
{
public class HomePage : ContentPage
{
Label lTitle;
Entry eURL;
Button bButton;
public HomePage()
{
lTitle = new Label
{
Text = "WELCOME",
HorizontalOptions = LayoutOptions.Center,
FontAttributes = Font.SystemFontOfSize(25, FontAttributes.Bold).FontAttributes,
FontSize = Font.SystemFontOfSize(25, FontAttributes.Bold).FontSize,
//WidthRequest = 200,
HeightRequest = 100
};
eURL = new Entry { Placeholder = "Enter Site URL", };
bButton = new Button { Text = "ENTER", };
bButton.Clicked += bButton_Clicked;
this.Content = new StackLayout
{
Children = {
lTitle, eURL, bButton
}
};
}
void bButton_Clicked(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(eURL.Text)) { DisplayAlert("URL", "Your URL is Empty", "OK"); }
else
{
SitePage.LoadRequest(new SitePage(eURL)));
}
}
}
}
,並從按鈕bButton的點擊打開EURL和網站加載到到名爲SitePage
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace zaposta_angelar
{
public class SitePage : NavigationPage
{
private Entry eURL;
public SitePage()
{
}
public SitePage(Entry eURL)
{
// TODO: Complete member initialization
this.eURL = eURL;
}
internal static void LoadRequest(SitePage sitePage)
{
throw new NotImplementedException();
}
}
}
代碼不起作用另一個頁面,任何出路
或者您可以使用一個CustomRenderer並使用新的SFSafariViewController所以用戶不必離開應用程序,但是擁有不錯的網絡瀏覽器功能 –