Esempio n. 1
0
 /// <summary>
 /// This function removes badge from current application.
 /// </summary>
 private void ResetBadge()
 {
     BadgeValue = 0;
     try
     {
         BadgeControl.Remove(applicationId);
     }
     catch (Exception e)
     {
         Log.Debug("Badges", $"Error when removing badge. {e.GetType()}, {e.Message}");
     }
 }
Esempio n. 2
0
        public void SetBadge(int?value)
        {
            var appId = Application.Current.ApplicationInfo.ApplicationId;

            try
            {
                BadgeControl.Remove(appId);
            }
            catch (InvalidOperationException)
            {
                // This exception is thrown when the badge does not exist.
                // Seems there is no way to check if the badge exists.
            }

            if (value != null)
            {
                Badge badge = new Badge(appId, value.Value);
                BadgeControl.Add(badge);
            }
        }