使用 Elmish.WPF (F#) 管理 WPF 选项卡控件?

Managing a WPF Tab Control with Elmish.WPF (F#)?

我在主 window 中有一个复杂的 WPF Tab 控件,全部使用 C#,使用 .NET Framework。主要 window 提供一致的主菜单和包含选项卡控件的内容控件。

选项卡控件的每个选项卡使用特定于每个用户控件的视图模型呈现不同的用户控件。

在进入兔子洞之前,我需要知道 Elmish.WPF 是否可以为这种情况提供适当的 F# 支持。

在研究示例时,Elmish.WPF 的密钥切换似乎发生在:

Program.mkSimpleWpf App.init App.update bindings

一旦主 window 和第一个选项卡出现,init、update 和 bindings 是否可以被区分并允许用户在选项卡之间切换?如果是这样,新的标签状态可以“喂”到Elmish.WPF吗?

如有任何帮助或建议,我们将不胜感激。

TIA

(为了使事情更加复杂,其中一个选项卡显示了一个带有用于列表操作的自定义装饰器的数据网格)。

我是 Elmish.WPF 的维护者。

I have a complex WPF Tab control inside a main main window, all in C#, using .NET Framework. The main window provides a consistent main menu and a contentcontrol holding the Tab Control.

Each tab of the tab control presents a different usercontrol using a viewmodel specific to each usercontrol.

Before going down the rabbit hole, I need to know if Elmish.WPF can provide the proper F# backing for this situation.

对于这个场景,是的,应该没有问题。我们目前在 repo 中没有使用选项卡控件的示例,但总的来说,您可以在 WPF 中使用绑定(以及一些)实现的所有内容也可以在 Elmish.WPF 中实现。如果您在学习 samples and official tutorial.

后无法正常工作,请在 Elmish.WPF 仓库中提出问题

Once the main window and the first tab are presented, can init, update, and bindings be discriminated unions allowing the user to switch between the tabs? If so, can the new tab state be "fed" into Elmish.WPF?

我有点不确定你在这里问什么,但你可能对一些核心 MVU 概念感到困惑。 Elmish.WPF tutorial or other resources mentioned in the Elmish.WPF readme 可能会有帮助。一般来说,消息类型是一个discriminated union,model是一个record。另一方面,initupdatebindings 是作用于模型和消息的 函数

(To further complicate matters, one of the tabs presents a datagrid with custom adorners for list manipulation).

我不是 WPF 选项卡控件方面的专家,但 AFAIK 选项卡的内容不应以任何方式影响 Elmish.WPF 是否与选项卡控件一起使用。