大家早上好,
我正在使用Xamarin.Forms开发一个小型跨平台Webview项目。我已经实现了Webview功能,但是我想添加一个工具栏,在其中放置返回和前进按钮。
我尝试了多种不同的方法,但似乎没有什么特别好的效果。我试图按照这个人的帖子导航工具栏来实现此功能。
我将我的代码附在下面,如果有人能帮我或者提供解决方案,那就太好了!
如果这个问题之前已经被其他用户回答过了,那我道歉。
App.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace DisplayWebPage
{
public class App : Application
{
public App()
{
// The root page of your application
MainPage = new WebPage();
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
WebPage.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using Xamarin.Forms;
namespace DisplayWebPage
{
public class WebPage : ContentPage
{
public WebPage()
{
Content = new StackLayout
{
Children = {
new WebView
{
Source = "http://www.google.com"
}
}
};
}
}
}
我一直卡在这个问题上,希望能得到答案。
祝好
public App() { // The root page of your application MainPage = new NavigationPage(new WebPage()); }
但现在 WebView 没有显示出来。有什么想法吗?我在某个地方读到过,每个 ContentPage 只能有一个项目,这可能是问题吗? - DugganWebView
设置WidthRequest
和HeightRequest
。 - Gerald Versluis