Search code examples
f#vsix

Template for F# and WPF (Visual Studio 2019 Community)?


As a newbie to F#, I have read many references to starting a new project with the "F# Empty Windows Application (WPF)". However, the template does not show up in my Visual Studio 2019 Community edition. Downloading and installing it fails as well.

Is there a good template to start a new project in F# for WPF?

Thanks in advance.


Solution

  • There are no templates because there are no designers that map XAML to F# code however you can use the following alternatives:

    • You can create a C# project and build your UI and then take the XAML into an F# project by leveraging the XAML type provider which will get you the structure and types of your UI components. There is a nice tutorial here although I haven't tried it myself and it might be a bit old.

    • You can use the C# XAML generated and do the binding manually in an empty F# project .

    • You can use the generated XAML and Elmish.WPF using the MVU model which I suggested earlier.

    • You can avoid XAML altogether and use Fabulous to build the UI programatically. This uses Xamarin though. This has however, some nice project templates and also follows the MVU model.