Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/NotifyIconWpf/TaskbarIcon.Declarations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,50 @@ internal static RoutedEventArgs RaiseBalloonClosingEvent(DependencyObject target

#endregion

#region BalloonClosed

/// <summary>
/// BalloonClosed Attached Routed Event
/// </summary>
public static readonly RoutedEvent BalloonClosedEvent = EventManager.RegisterRoutedEvent("BalloonClosed",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));

/// <summary>
/// Adds a handler for the BalloonClosed attached event
/// </summary>
/// <param name="element">UIElement or ContentElement that listens to the event</param>
/// <param name="handler">Event handler to be added</param>
public static void AddBalloonClosedHandler(DependencyObject element, RoutedEventHandler handler)
{
RoutedEventHelper.AddHandler(element, BalloonClosedEvent, handler);
}

/// <summary>
/// Removes a handler for the BalloonClosed attached event
/// </summary>
/// <param name="element">UIElement or ContentElement that listens to the event</param>
/// <param name="handler">Event handler to be removed</param>
public static void RemoveBalloonClosedHandler(DependencyObject element, RoutedEventHandler handler)
{
RoutedEventHelper.RemoveHandler(element, BalloonClosedEvent, handler);
}

/// <summary>
/// A static helper method to raise the BalloonClosed event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
/// <param name="source">The <see cref="TaskbarIcon"/> instance that manages the balloon.</param>
internal static RoutedEventArgs RaiseBalloonClosedEvent(DependencyObject target, TaskbarIcon source)
{
if (target == null) return null;

RoutedEventArgs args = new RoutedEventArgs(BalloonClosedEvent, source);
RoutedEventHelper.RaiseEvent(target, args);
return args;
}

#endregion

//ATTACHED PROPERTIES

#region ParentTaskbarIcon
Expand Down
2 changes: 2 additions & 0 deletions src/NotifyIconWpf/TaskbarIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ public void CloseBalloon()
// close the popup
popup.IsOpen = false;

RaiseBalloonClosedEvent(element, this);

// remove the reference of the popup to the balloon in case we want to reuse
// the balloon (then added to a new popup)
popup.Child = null;
Expand Down