3

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.

In studying the examples, the key handoff to Elmish.WPF seems to occur with:

Program.mkSimpleWpf App.init App.update bindings

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?

Any help or suggestions would be most appreciated.

TIA

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

Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
  • 1
    I feel like there are many questions in there. Let's try to address them one at a time. Elmish.WPF is designed to be fully in control of all Windows. However, this is not required. Do you want Elmish.WPF to be fully in control of all your WIndows? – Tyson Williams Aug 13 '20 at 18:53
  • 2
    https://github.com/BentTranberg/ExploreElmishWpf – Bent Tranberg Aug 14 '20 at 07:20
  • @TysonWilliams I am a very newbie to F# and Elmish. Ideally, the more in F# the better. That is I'm trying to get a handle on Events and binding from C# WPF to F#. In the standard Visual Studio (2019), the Output Window helps tremendously with binding errors. This does not seem to work with F# ??. Ultimately, if I could use only WPF, F#, (and C# only when necessary), that would be ideal. At this point, I'm trying to understand how to use Elmish.wpf when the window has not yet been constructed in real-time. (As in the Tab Control). – Alan Wayne Aug 14 '20 at 18:21
  • 1
    I feel like there are many things in your previous comment as well. Let me try to briefly address them. (1) Converting C# to F# is difficult if you don't already have some experience with F#. I recommend (practice) writing new F# code first. (2) Binding errors and Visual Studio's Output window work the same with Elmish.WPF as with a normal WPF app, but Elmish.WPF provides additional information when this happens. (3) My Elmish.WPF application at work contains almost no C#. (4) I don't know what you mean by "when the window has not yet been constructed in real-time." – Tyson Williams Aug 14 '20 at 19:45
  • 2
    @AlanWayne, the app in the repo I linked to uses tabs, sort of, with each tab containing one distinct user control. I suspect that's what you're looking for. – Bent Tranberg Aug 14 '20 at 20:37
  • @BentTranberg This is great! Please stay tuned as I attempt to understand it ...:) Is there a reference to the types and functions defined by the Elmish.WPF framework? – Alan Wayne Aug 15 '20 at 03:16
  • 1
    @BentTranberg It seems that Binding.subModelSeq does most of what I need. Thanks! – Alan Wayne Aug 15 '20 at 05:56
  • 1
    The answer by cmeeren links to the documentation. cmeeren and Tyson Williams are the two major contributors to Elmish.WPF these days, and has been for a long time. I am certainly no expert, but is one of many that try to help a little now and then with small details if able to. Wish I could do more. You can find us on F# Slack and in other forums. Issues can be posted in the repos, e.g. suspected bugs, suggestions for functionality and improved documentation. – Bent Tranberg Aug 16 '20 at 06:04

1 Answers1

5

I am a maintainer of 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.

For this scenario, yes, there should be no problems. We currently have no samples in the repo that use tab controls, but in general, everything you can achieve with bindings (and then some) in WPF can also be achieved in Elmish.WPF. Please open an issue in the Elmish.WPF repo if you are unable to get it working after studying the samples and 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?

I am a bit unsure what you're asking here, but it is possible you are confused about some central MVU concepts. The Elmish.WPF tutorial or other resources mentioned in the Elmish.WPF readme may be of help. In general, the message type is a discriminated union, and the model is a record. On the other hand, init, update and bindings are functions that act on the model and the messages.

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

I'm no expert on WPF tab controls, but AFAIK the contents of the tab should not impact in any way whether Elmish.WPF works with a tab control.

cmeeren
  • 3,890
  • 2
  • 20
  • 50