我是Elmish.WPF和F#的新手。在学习有关NewWindow/NewWindow.Views的教程时,作者从C#分配了以下代码:
using System;
using Elmish.WPF.Samples.NewWindow;
using static Elmish.WPF.Samples.NewWindow.Program;
namespace NewWindow.Views {
public static class Program {
[STAThread]
public static void Main() =>
main(new MainWindow(), () => new Window1(), () => new Window2());
}
}即调用F# NewWindow.Views项目中的main方法:
let main mainWindow (createWindow1: Func<#Window>) (createWindow2: Func<#Window>) =
let createWindow1 () = createWindow1.Invoke()
let createWindow2 () =
let window = createWindow2.Invoke()
window.Owner <- mainWindow
window
let bindings = App.mainBindings createWindow1 createWindow2
Program.mkSimpleWpf App.init App.update bindings
|> Program.withConsoleTrace
|> Program.runWindowWithConfig
{ ElmConfig.Default with LogConsole = true; Measure = true }
mainWindow如何更改F#模块的主例程,以便直接将其用作EntryPoint,并避免它成为一个函数?也就是说,我希望F#模块能够通过Elmish直接控制窗口。如下所示,但是调用了独立的从属窗口:
/// This is the application's entry point. It hands things off to Elmish.WPF
[<EntryPoint; STAThread>]
let main _ =
Program.mkSimpleWpf init update bindings
|> Program.runWindow (MainWindow())简而言之,我希望C#视图不了解F#项目。
这可以用Elmish.wpf来完成吗?
任何帮助(特别是示例代码:)将是最有帮助的。
发布于 2020-08-14 02:31:48
我是Elmish.WPF的维护者之一,直到最近,所有的示例都使用他们的F#项目作为入口点。如果您克隆存储库并签出this commit,那么您可以检查这些示例,并查看如何实现您的目标。
接下来,我创建了this issue,以考虑至少包含一个带有F#项目的示例作为其入口点。
将来,您可以通过在our GitHub中打开一个问题来询问您的任何Elmish.WPF问题。
https://stackoverflow.com/questions/63348787
复制相似问题