Can't keep reference to desktop alert

2 posts, 0 answers
  1. MartinM
    MartinM avatar
    3 posts
    Member since:
    Dec 2009

    Posted 28 Jul 2015 Link to this post

    Using WinControls version 2014.3.1202.40

    I am attempting to keep a list of all popups that have been displayed so far so I can programmatically close certain popups based on a condition, later. So after creating a list and adding a reference of a popup to it, the reference to it in the list disappears after calling .show() on the alert object.

    A simple example:


    var listOfPopups = new List<RadDesktopAlert>();
    var alert = new RadDesktopAlert();
    listOfPopups.Add(alert); // listOfPopups.Count == 1 now.
    alert.Show(); // listOfPopups.Count == 0 now...


    Is this by design? And if so, is there any other way to keep track of them, or get access to the popups through the desktopAlertManager?





  2. Hristo Merdjanov
    Hristo Merdjanov avatar
    664 posts

    Posted 29 Jul 2015 Link to this post

    Hi Martin,

    Thank you for writing. 

    I tested your scenario with a list and a dictionary and I am able to access the already displayed alerts and hide them. Please check my example below: 
    public partial class Form1 : Form
        private IDictionary<int, RadDesktopAlert> alerts;
        public Form1()
            this.alerts = new Dictionary<int, RadDesktopAlert>();
        private void btnAddAlert_Click(object sender, EventArgs e)
            RadDesktopAlert alert = new RadDesktopAlert();
            alert.AutoClose = false;
            alert.CaptionText = "New Alert";
            alert.ContentText = "Some text";
            alerts[this.alerts.Count] = alert;
        private void btnFindAlert_Click(object sender, EventArgs e)
            int id;
            bool isInteger = int.TryParse(this.tbId.Text, out id);
            if (isInteger)
                 if (alerts.ContainsKey(id))

    As to the DesktopAlertManager, it is basically responsible for setting the position of each alert when it is being created. Just before an alert is shown it gets registered by the alert manager and its coordinates are calculated depending on the screen settings and the other alerts which are already shown.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top