question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WindowNotificationManager can't be used immediately after creating

See original GitHub issue

Click the interface test button, the notification cannot be displayed and the error will be reported directly

@ForNeVeR @mterwoord @vmrocha @lontivero

 private void btn_TestClike(object sender, RoutedEventArgs e)
        {
            WindowNotificationManager _notificationManager = new WindowNotificationManager(this)
            {
                Position = NotificationPosition.TopRight,
                MaxItems = 3
            };

            _notificationManager.Show(new NotificationModel
            {
                Title = "1234",
                Message = "12345",
                Type = NotificationType.Information,
                Expiration = TimeSpan.FromSeconds(100000)
            });


            //NotificationManager.Show(new NotificationModel{ 
            //    Title = "Hey There!", 
            //    Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" });

        }
public class NotificationModel: INotification
    {

        public string Title { get; set; }
            public string Message { get; set; }

            public NotificationType Type { get; set; }

            public TimeSpan Expiration { get; set; }

            //public Action OnClick { get; set; }

            //public Action OnClose { get; set; }



        public Action OnClick => () => Console.WriteLine("helloworld");

        public Action OnClose => () => Console.WriteLine("Stw");

    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
HossamElwahshcommented, Oct 14, 2022

Probably too late but if anyone facing the same issue, this is the correct way to show it directly as per maxkatz6 instructions

var not = new Notification("Test", "this is a test notification message", NotificationType.Success);
        var nm = new WindowNotificationManager(this)
        {
            Position = NotificationPosition.BottomRight,
            MaxItems = 1
        };
        nm.TemplateApplied += (sender, args) =>
        {
            nm.Show(not);
        };
0reactions
coraxxcommented, Apr 27, 2023

If somebody has the same problem I had. I was initializing it in the MainWindow’s ctor but it did not show for me. Only after moving it to e.g. Window_OnLoaded:

private void Window_OnLoaded(object? sender, RoutedEventArgs e)
{
    _notificationManager = new WindowNotificationManager(this)
    {
        Position = NotificationPosition.TopRight,
        MaxItems = 5
    };
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and manage notification channels
After you create a notification channel, you can't change the notification behaviors. The user has complete control at that point.
Read more >
NotificationManager.notify() not launching full-screen intent ...
I have an alarm clock app and since android 10 I have to use full-screen intents to trigger the alarms. When the device...
Read more >
Notification Manager in Android
Developers can use the NotificationManager class to create and manage notifications within their apps. To create a notification, ...
Read more >
Android Notification, PendingIntent Example
In this tutorial we'll create an application that wraps an intent that would view a webpage, into a PendingIntent.
Read more >
How To Make A Simple Notification Manager - Unity Tutorial
In this video series I will show you many tips and tricks that you must know about when it comes do game design,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found