Elmish.WPF icon indicating copy to clipboard operation
Elmish.WPF copied to clipboard

[Samples] Raising events from program to UI

Open xperiandri opened this issue 3 years ago • 1 comments

Doing Elmish.Uno development we came to a need of raising an event that must be handled on UI (display iOS printer picker)

The approach is to create a class that holds all the events. That class instance is returned via binding but event sources that can be triggered are located in an Elmish program.

type EventsHolder (pickPrinterEvent) =
    [<CLIEvent>] member _.PickPrinter = pickPrinterEvent.Publish

let pickPrinterEvent = Event<,>

"Events" |> Binding.oneWay (fun m -> m.Events)

On UI EventTrigger is used to subscribe

xperiandri avatar Mar 06 '21 20:03 xperiandri

I solved a problem in my application at work by passing a FrameworkElement to the F# code and then using it to create an Elmish Cmd.

I wonder if this is relevant here.

Can you link to sample code that shows this functionality in action?

TysonMN avatar Mar 07 '21 12:03 TysonMN