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

标签 f# elmish-wpf

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

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

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

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

Program.mkSimpleWpf App.init App.update bindings

一旦主窗口和第一个选项卡出现,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 中使用绑定(bind)(以及一些)实现的所有内容也可以在 Elmish.WPF 中实现。如果您在学习了 samples 后仍无法正常工作,请在 Elmish.WPF 存储库中提出问题和 official tutorial .

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 tutorialElmish.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 选项卡控件方面的专家,但据我所知,选项卡的内容不应以任何方式影响 Elmish.WPF 是否与选项卡控件一起使用。

关于f# - 使用 Elmish.WPF (F#) 管理 WPF 选项卡控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63401135/

相关文章:

f# - 类型 Elmish.WPF main() 函数将绑定(bind) () -> #Window 报告为错误

generics - f# 泛型类型比较

exception - F# - 为什么 Seq.map 不传播异常?

casting - F#:转换 seq <'A> to seq<' B> 的最快方法

f# - LiveCharts LabelFormatter 的 Elmish.Wpf 绑定(bind)

c# - f# 读取 xls 文件 - 如何解析 value2 对象

string - F# 将字符串数组转换为字符串

asynchronous - 从异步函数内部更改 Elmish.WPF 模型

f# - 在 FsXaml 和 ElmishWPF 中更新 ProgressBar.Value