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.
source share