At the risk of beating a dead horse, I would like to be clear on the initial setup for using Elmish.WPF.
My intent is to have essentially two projects:
- FrontOfficeV -- a C# project to hold the XAML's, Windows, etc..
- Models -- a F# project for Elmish.WFP, F# code, etc..
After trying most all of the project type options (Visual Studio 2019), I settled on: Console App (.NET Framework) C# for the C# Project.
This created the C# project that defaulted to: Target framework: .NET Framework 4.7.2 Output type: Console Application. This also created a "program.cs" file.
Next, using ADD -->New Item with the C# Console App did not show a "Window" option. It did show the "User Control (WPF)" option. So the "User Control (WPF) was added and renamed to "MainWindow". I then changed the element tag in the xaml from UserControl to Window and changed the code behind to inherit from Window instead of UserControl. Lastly, I changed the project properties to compile output type to: Windows Application. This C# project was now marked as the "StartUp" project for visual studio.
Next, the F# Models project was created using: Library (.NET Framework) F# Windows library. This created a project which defaulted to: Target framework: .NET Framework 4.7.2 Output type: Class Library. To the F# class library, a program -- FrontOffice.fs, was added with:
/// This is the application's entry point. It hands things off to Elmish.WPF
let entryPoint (mainWindow: Window) =
Program.mkSimpleWpf init update bindings
|> Program.runWindowWithConfig
{ ElmConfig.Default with LogTrace = true; Measure = true; MeasureLimitMs = 1 }
mainWindow
Lastly, the program.cs was changed to read:
public class Program
{
[STAThread]
public static void Main(string[] args)
{
Application app = new Application();
Window mainWindow = new MainWindow();
Models.FrontOffice.entryPoint(mainWindow);
}
}
The point here being the usage of: Program.mkSimpleWpf.
Why all the hassle? I would like to use the full WPF/C#/XAML goodies (like Themes, custom controls, etc), and I am not so sure the direct compilation of XAML in F# can do this. I'd like to be able to use the F# data types in the XAML, so the C# project requires a reference to the F# Modules, so it seems easier to create the windows in C# and pass a reference unto the F# Modules entryPoint, as above.
Questions:
- Is the setup above correct for Elmish.WPF?
- Is there a better setup to accomplish my goals?
- As of Visual Studio 2019, does F# compilation of the xaml work for themes, custom controls, etc? What hiccups can I expect?
Thank you for any clarification on these points. TIA