Open ScottHutchinson opened 4 years ago
Yeah, I agree. For completeness, we might want one sample that does not use Elmish for the main application, and one that does use it.
Also, since the Program.startElmishLoop
is public, I can also do it like below without modifying Elmish.WPF at all. We could still add sample(s) showing how to do this. It seems obvious and trivial now, but it took me a couple days of frustration before I figured it out.
let showDialogWithConfig config (window: Window) program =
Program.startElmishLoop config window program
window.ShowDialog ()
Program.mkSimpleWpf init App.update App.rootBindings
|> showDialogWithConfig
ElmConfig.Default
(MsgTypeFiltersWindow())
|> ignore
Since Program.startElmishLoop
is already public, I think it is not worth adding another public function to also show a Window
as a dailog.
Brilliant! Let's just focus on a sample, then.
Personally I think it's sufficient to show a non-Elmish app using Elmish.WPF for sub-windows. Using separate Elmish dispatch loops for an app that already runs Elmish.WPF at the root seems unnecessary and, while possible, not something that anyone would really want to do. Feel free to enlighten me with counter-examples, though.
In my application, another project calls the
LoadWindow
function shown below. But after the user closes theMsgTypeFiltersWindow
window and attempts to open it again by calling theLoadWindow
function again, I get'System.InvalidOperationException' in PresentationFramework.dll The Application object is being shut down.
.How can I write the
LoadWindow
function so it can be called over and over again?Thanks