What is a good approach to displaying a dialog box with Gjallarhorn?

There are many questions about a few good approaches to displaying a dialog box for MVVM. But I see that Gyallarhorn looks different.

I need to show pairs of dialogs, for example, I have one action for each dialogue.

type Action = |Show |Open |Input |Change |Statistic 

and several windows

 module Views open FsXaml ... type StatisticWindow = XAML<"StatWindow.xaml"> type InputWindow = XAML<"InputWindow.xaml"> ... 

way to show it

 let showDialog (context:BindingSource) (view : System.Windows.Window) = view.DataContext <- context view.ShowDialog() |> ignore let getViewByAction = function |Statistic -> Views.StatisticWindow() :> System.Windows.Window |Input -> Views.InputWindow() :> System.Windows.Window | ... let getContextByAction model = function | Statistic -> statContext model | Input -> inputContext model | ... let performAction model action = let context = getContextByAction model action getViewByAction action |> showDialog context 

An appropriate approach for this purpose?

PS I don’t know why, but I feel that there is a cleaner solution there.

+5
source share
1 answer

There is currently no great solution. The application architecture was based (weakly) on Elm, which focuses on single-page applications, which does not really include "user dialogue support."

Right now, the approach you are using is likely to be similar to what I would recommend.

At the same time, it is planned to implement a complete navigation environment, and the windows / dialogs on the desktop will be taken into account in this project. In the future, there will most likely be landmarks around this.

+4
source

Source: https://habr.com/ru/post/1270661/


All Articles