我是F#的新手。我最近被介绍了Elmish.wpf和MVU的设计。我正在使用的应用程序是具有许多C#用户控件、自定义控件和窗口的WPF。看起来,Elmish.wpf将视图模型的概念扁平化到单个数据上下文中。(??)。Elmish.wpf可以与多个窗口、用户控件和自定义控件一起使用吗?(这里的“多个”是指大约20个窗口、用户控件和自定义控件。)
如果是这样,有没有这样的例子?
在Elmish.wpf the端,似乎所有窗口都需要在初始化时创建--
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有没有更好的方法来做这件事?我是不是找错人了?
提前谢谢。
发布于 2020-08-14 03:05:20
是的,Elmish.WPF绝对支持多窗口和用户自定义控件。
许多samples in the Elmish.WPF repo以这样或那样的方式演示了这一点。例如,NewWindow示例演示了如何打开新窗口,SubModel (以及许多其他示例)演示了如何使用自定义UserControl。SubModelSeq示例是目前最复杂的示例,它演示了任意深的递归UserControl树。
所有这些都在the official Elmish.WPF tutorial中进行了描述。
(为便于将来参考,请参阅this is the current commit at the time of writing;从那时起,样本可能已更改。)
https://stackoverflow.com/questions/63333098
复制相似问题