Click or drag to resize
Overview & FAQ

Welcome to the C#/XAML for HTML5 documentation.

We keep adding new content to the documentation on a regular basis. If you have a specific topic that you would like mentioned here, please send us an email to: feedback@cshtml5.com

This topic contains the following sections:

What is CSHTML5?

CSHTML5 (aka C#/XAML for HTML5) is a free extension for Visual Studio that lets developers write apps in standard C#/XAML and compile them into cross-platform HTML5/JavaScript.

The generated apps can run natively on any web browser, without the need for any plugin or installation, and they can also be packaged as stand-alone apps for iOS and Android.

How does it work?
  1. You download and install C#/XAML for HTML5 from http://www.cshtml5.com

    It will add a new project type to the Visual Studio "New Project" dialog.

    New Project Dialog 1 smaller
  2. You create a new empty project of type "C#/XAML for HTML5".

    It is a special kind of project that supports a subset of Silverlight/WinRT.

  3. You write C# and XAML code until you reach the desired result. Every time you click "Start", the C#/XAML code gets compiled into HTML5 and JavaScript, allowing you to test the application in your web browser. You never need to manually modify the generated HTML5 and JavaScript files.

  4. When you are done, you can either upload the generated HTML5 and JavaScript files to a file server for online access - such as Azure or your own website -, or you can package the generated files into a stand-alone application for Android, iOS*, Windows, Mac, Linux, WP, ChromeOS, etc., and submit it to stores such as the Apple App Store*, Android Google Play, the Windows Store, and more.

    Note Note

    * Note: Apple requires users to have access to a Mac or to have a valid PhoneGap Build subscription in order to be able to compile apps for iOS or to publish them to the Apple App Store. This requirement applies to all the solutions in the market.

How does it compare to other tools for building cross-platform apps?

CSHTML5 is currently the only tool that lets developers build truly cross-platform apps using only standard C# and XAML with Visual Studio.

  • Xamarin:

    • Apps cannot run in web browsers, nor can they run on platforms such as Linux, ChromeOS, Tizen, and more.

    • The XAML language used in Xamarin.Forms is very different from the XAML used in Universal Windows Apps, Silverlight, WPF, and Windows Phone. The names, properties, and methods are different.

    • Extending the built-in features requires coding natively for each individual platform. In contrast, CSHTML5 allows extending the built-in C#/XAML/.NET features by writing custom JS/HTML5 code that works on all platforms.

  • ASP.NET:

    • Apps are not XAML-based.

    • C# code can only be executed on the server, not on the client, so it is not possible to write apps in C# that can run offline on mobile platforms such as iOS or Android.

  • TypeScript and other solutions:

    • They are not based on C#, XAML, and the .NET Framework, so they don't allow to reuse the existing skills and codebase, to share code between the client and the server, to migrate Silverlight apps, etc.

Why use the C# and XAML languages to build cross-platform apps?

Because with C# and XAML you can:

  • Use your existing development skills.

  • Port Silverlight or other existing apps to the web.

  • Share C# code between the client and the server.

  • Leverage the power of .NET and XAML (user controls, binding, data templates, type safety, async/await, linq...)

  • Share code with projects of other types (WPF, Windows Phone, Universal Apps...)

  • Extend the reach of Universal Apps beyond the Microsoft ecosystem.

  • Use a well-known standard language rather than relying on a myriad of JavaScript frameworks.

How to migrate an existing Silverlight, WPF, WinRT, or WinPhone application?
  1. Create a new empty project of type "C#/XAML for HTML5". If your existing application is made of multiple Visual Studio projects, create one new project of type "C#/XAML for HTML5" for each of the projects that you are migrating.

  2. Copy/paste the C#/XAML files from the original project(s) into the new project(s). Note: for C# files, instead of copying the files, you can use the "Add as link" feature of Visual Studio that enables you to share the same file between the original project and the new project. This is only useful for C# files, because XAML code does not allow compiler directives.

  3. Comment out the portions of the code that are not supported. For C# code, instead of commenting out the code that is not supported, you can surround it with the "#if !CSHTML5" compiler directive, so that the original code remains intact. For best productivity, we recommend an iterative approach, where you start with almost all the code commented out, and you progressively include the code into the "C#/XAML for HTML5" projects while at the same time verifying that it compiles properly.

  4. Run the project to see if the generated HTML5/JavaScript runs wells. Please note that the migration is not a "one-time" conversion: even after you have finished migrating your application, you keep working in C#/XAML, not HTML/JavaScript. In fact, you never need to manually modify the generated HTML5 and JavaScript files.