有没有办法激活控件 WebView 桌面模式而不是移动模式?

there is a way to activate a control WebView Desktop mode and not Mobile mode?

有没有办法激活控件 WebView 桌面模式而不是移动模式?

<WebView x:name= "WebViewApp" ..../>

WebView 没有固有的桌面或移动模式。站点是否提供移动或桌面优化站点通常基于用户代理 header。您可以通过创建 HttpWebRequest with the agent you want and then navigating with WebView.NavigateWithHttpRequestMessage.

在 WebView 中进行设置

如果您想模仿特定的浏览器模式,您可以在多个网站上找到它使用的用户代理。

string userAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop) like Gecko"
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(
    HttpMethod.Post, new Uri("http://whatsmyuseragent.com"));
httpRequestMessage.Headers.Append("User-Agent",userAgent);

myWebView.NavigateWithHttpRequestMessage(httpRequestMessage);

您可以尝试向 <head> 添加宽度为 "desktop" 的视口元标记,例如:

<meta name="viewport" content="width=1024">

<meta name="viewport" content="width=1024,initial-scale=1, maximum-scale=1, user-scalable=no">

试试这个来设置你的用户代理:~

webView.SetWebViewClient (new MyWebViewClient());

// ...

public class MyWebViewClient : WebViewClient
{
    public override bool ShouldOverrideUrlLoading(WebView view, string url)
    {
        view.Settings.UserAgentString = "your-user-agent-here";
        view.LoadUrl(url);
        return true;
    }
}