Wednesday, March 03, 2021

F# and OpenSilver -- first steps

This set of lab notes turned into a series of 3 posts.


Many years ago, I made a series of posts experimenting with F# (then still in preview) and Silverlight

  • documenting some of the hacks required to get it to work. Now, more than a decade later, WASM is the new in-browser hotness, with many approaches to getting your non-JS code to run in browser.

    One of these is OpenSilver, which is intended as a near as possible drop-in replacement for Silverlight. Like the original, it assumes C# and XAML with code-behind first, but let's see what we can do about that...

    Assuming you have OpenSilver set up, then the equivalent of the first post above is relatively simple. Make a new OpenSilver application solution, then replace the actual application project with a new netstandard2.0 F# library (in the solution and as a project reference in the two helper projects). Add OpenSilver as a nuget package to the F# project, then paste in the code from the same first working example to replace the initial stub code. In the .Browser project, fix the type of the App class -- new SilverLightFSharp.MyApp(); -- and then run whichever helper.

    It should look like this :--

    in the simulator after you click the button.

    Next -- Adding XAML, initial attempts

    No comments :