首页 > 解决方案 > C# Xaml WebBrowser.DocumentText Youtube 错误

问题描述

我有问题WebBrowser.DocumentText

我收到此错误:

WebBrowser 不包含“DocumentText”的定义,并且找不到接受“WebBrowser”类型的第一个参数的可访问扩展方法“DocumentText”(您是否缺少 using 指令或程序集引用?

代码 :

string _yUrl;
public string VideoID
{
    get
    {
        var yMatch = new Regex(@"http(?:s?)://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)([\w\-]+)(&(amp;)?[\w\?=]*)?").Match(_yUrl);
        return yMatch.Success ? yMatch.Groups[1].Value : string.Empty;
    }
}
   
private void btnGo_Click(object sender, EventArgs e)
{
    _yUrl = https://www.youtube.com/watch?v=cZ1Z0zZHktI;
        webBrowser.DocumentText = String.Format("<meta http-equiv='X-UA-Compatible' content='IE=Edge'/><iframe width='100%' height='315'" +
        " src='https://www.youtube.com/embed/{0}?autoplay=0' frameborder='0' allow='accelerometer;" +
        " encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>", VideoID);
}

标签: c#wpfxaml

解决方案


推荐阅读