fsprojects / Avalonia.FuncUI

Develop cross-plattform GUI Applications using F# and Avalonia!
https://funcui.avaloniaui.net/
MIT License
955 stars 74 forks source link

Avalonia Notifications not showing up on MainWindow. #329

Closed wjrivera closed 8 months ago

wjrivera commented 1 year ago

I believe that Avalonia.Controls.Notifications not showing up on MainWindow, but I could be wrong. Here is an example: https://github.com/wjrivera/avalonia-funcui-notifications/blob/master/Program.fs

type MainWindow() as this =
    inherit HostWindow()

    do
        base.Title <- "application"

        let topLevel = TopLevel.GetTopLevel(this)
        let windowManager = new WindowNotificationManager(topLevel)
        let notification = new Notification("Title", "Message", NotificationType.Information)
        windowManager.Show notification

        Elmish.Program.mkProgram (Main.init topLevel) Main.update Main.view
        ...

I've tried running it from the MainWindow (HostWindow) and Main itself and nothing happens. Would like to get your opinion on the matter. Thank you

Numpsy commented 1 year ago

I've never tried using it myself, but the post at https://github.com/AvaloniaUI/Avalonia/issues/5442 says that you can't open notificiations immediately after creating the manager and need to wait for it to initialize instead

wjrivera commented 1 year ago

In the https://github.com/fsprojects/Avalonia.FuncUI/issues/Program.fs I posted above, I called the notification in 3 places, including on Main.update (at button click). I would think that by then, it would be initialized.

JaggerJo commented 8 months ago

I'm closing this. Feel free to reopen if you still have the issue.