0

I want to use Google blockly in my C# Window Form. I'm using inbuilt Webbrowser in my application. Here is Code :

   namespace WbView
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                WebBrowser browser = new WebBrowser();
                browser.Navigate("https://blockly-demo.appspot.com/static/demos/interpreter/step-execution.html");
                browser.Width = 800;
                browser.Height = 600;
                this.Controls.Add(browser);
            }
        }
    }

When I'm running it first time I got Script Error like this enter image description here

But After that I changed some Registry entries and it works according to modern browsers

Registry Entries

enter image description here

But the Problem is Now I'm unable to use mouse to drag and drop Blocks not even zoom in or zoom out what I can use is just the toolbox to show blocks and nothing else. enter image description here

Does anyone faced this type of Problem? What have I done:

1. I have used CefSharp and it was works perfectly. but CefSharp Supports only > .net v4.x.x but I want that my application supports min. .NET v3.5 I want that my Application support windows 7, 8, 10

Community
  • 1
  • 1
Sunny Bhadana
  • 241
  • 3
  • 14

1 Answers1

0

What version of Windows do you need to support? If it's 1803 (this years April update) you can and should use this new/modern webview. https://blogs.windows.com/msedgedev/2018/05/09/modern-webview-winforms-wpf-apps/

Programmatically adding WebView

After installing the NuGet package, you can add the WebView to your application like any other control. The WinForms version of the control is in the Microsoft.Toolkit.Win32.UI.Controls.WinForms namespace. using Microsoft.Toolkit.Win32.UI.Controls.WinForms;

public partial class Form1 : Form
{
  public Form1()
  {
    InitializeComponent();

    // Initialize WebView and add it to the Window's controls
    var wvc = new WebView();
    ((ISupportInitialize)wvc).BeginInit();
    wvc.Dock = DockStyle.Fill;
    Controls.Add(wvc);
    ((ISupportInitialize)wvc).EndInit();

    // You can also use the Source property
    wvc.Navigate(new Uri("https://www.microsoft.com"));
}

Here is the Nuget: https://www.nuget.org/packages/Microsoft.Toolkit.Win32.UI.Controls/

Install-Package Microsoft.Toolkit.Win32.UI.Controls -Version 3.0.0

The browser component you are using right now is not good for modern web stuff.

JP Hellemons
  • 5,977
  • 11
  • 63
  • 128
  • hey! I'm getting this error Microsoft.Toolkit.Win32.UI.Controls 3.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. – Sunny Bhadana Jul 24 '18 at 08:17
  • Perhaps `install-package geckofx45` then. You need a different modern browser/webview then the old default one. – JP Hellemons Jul 24 '18 at 08:23
  • I have tried geckofx45 but it is not working as I want. It show pages more terrible ^_^ :P – Sunny Bhadana Jul 25 '18 at 05:58
  • cefsharp supports framework > 4.5.2 but I want my application run at least .net framework 3.5 – Sunny Bhadana Jul 26 '18 at 07:10
  • 3.5 was released in 2002. 4.5.2 is from May 2014 (also 4 years old) Perhaps move to .Net Core and Standard because you can include the framework in the build. Not being dependent to the installed version. – JP Hellemons Jul 26 '18 at 07:52