Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a webpage as the UI in a C# desktop application?

Tags:

html

c#

I'm building a C# desktop app with a simple UI. Due to my familiarity with HTML/CSS, and a previous web-based iteration of a very similar app, it would be ideal if I could re-use some existing HTML/CSS pages I have as the UI for this new desktop app.

Is that do-able with C#? Can anyone show a simple example of using an HTML/CSS page as the UI of a C# desktop application?

like image 883
Keith Palmer Jr. Avatar asked Mar 22 '11 12:03

Keith Palmer Jr.


4 Answers

Other answers are dated, new good options:

  • Electron + Electron-Edge - is the way to go for a new Electron app that communicates to a .NET backend (a DLL). Widely used and supported.
  • Neutronium - best for already-written .NET WPF apps that need a HTML UI. Requires using Vue. Less popular and less supported.
like image 172
Andrey Moiseev Avatar answered Nov 07 '22 01:11

Andrey Moiseev


CefSharp (https://github.com/cefsharp/CefSharp) is a good way to embed chromium, but you still need a web server. Take a look at http://www.ultidev.com/products/Cassini/ to alternative for IIS.

like image 45
Pedro Muniz Avatar answered Nov 07 '22 01:11

Pedro Muniz


You can use WebBrowser control to add Web browser functionality to your application.

You can create your own html(s) and set your WebBrowser control to display those pages. You can navigate by clicking hyperlinks or by using keyboard shortcuts to move backward and forward through navigation history. By default, you can access additional browser functionality through the right-click shortcut menu

You can even manage those pages centrally (for e.g. on LAN) and all clients on LAN can connect to this central location. This way you can modify pages centrally.

Check a walkthrough on MSDN:

How to: Add Web Browser Capabilities to a Windows Forms Application

like image 5
ukhardy Avatar answered Nov 07 '22 02:11

ukhardy


You can try to use a Chromium-based control - DotNetBrowser. This control provides wide interactivity options, like DOM manipulation and DOM events, which can be useful in your case.

In addition, there is an article that demonstrates how to use a web page as HTML UI in a C# desktop application: https://www.infoq.com/articles/html-desktop-net

Affiliation disclosure: I work with the team, which created DotNetBrowser.

like image 5
Eugene Yakush Avatar answered Nov 07 '22 03:11

Eugene Yakush