WPF NotifyIcon

--------------
CHG   DataContext now also set on ContextMenu property. Revamped DataContext handling, which
      now not only checks whether DataContext is not null, but also leaves DataContext of
      controls unchanged, if the DataContext is bound.
CHG   Some documentation changes and cleanup, added class diagram.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@100 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-05-12 11:24:22 +00:00
parent 98a0017687
commit 34c589eac4
7 changed files with 142 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Threading;
using Hardcodet.Wpf.TaskbarNotification.Interop;
using Point=Hardcodet.Wpf.TaskbarNotification.Interop.Point;
@@ -182,14 +183,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
{
CloseBalloon();
}
//create an invisible popup that hosts the UIElement
Popup popup = new Popup();
popup.AllowsTransparency = true;
//provide the popup with the taskbar icon's data context
popup.DataContext = DataContext;
UpdateDataContext(popup, null, DataContext);
//don't animate by default - devs can use attached
//events or override
@@ -314,8 +314,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
#region Process Incoming Mouse Events
/// <summary>
@@ -483,11 +481,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
//the ParentTaskbarIcon attached dependency property:
//tt.PlacementTarget = this;
//the tooltip (and implicitly its context) explicitly gets
//the DataContext of this instance. If there is no DataContext,
//the TaskbarIcon sets itself
tt.DataContext = DataContext ?? this;
//make sure the tooltip is invisible
tt.HasDropShadow = false;
tt.BorderThickness = new Thickness(0);
@@ -504,6 +497,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
tt.Content = ToolTipText;
}
//the tooltip explicitly gets the DataContext of this instance.
//If there is no DataContext, the TaskbarIcon assigns itself
if (tt != null)
{
UpdateDataContext(tt, null, DataContext);
}
//store a reference to the used tooltip
SetTrayToolTipResolved(tt);
}
@@ -566,11 +566,9 @@ namespace Hardcodet.Wpf.TaskbarNotification
//events or override
popup.PopupAnimation = PopupAnimation.None;
//the tooltip (and implicitly its context) explicitly gets
//the DataContext of this instance. If there is no DataContext,
//the TaskbarIcon assigns itself
popup.DataContext = DataContext ?? this;
//the CreateRootPopup method outputs binding errors in the debug window because
//it tries to bind to "Popup-specific" properties in case they are provided by the child
//not a problem.
Popup.CreateRootPopup(popup, TrayPopup);
//do *not* set the placement target, as it causes the popup to become hidden if the
@@ -582,6 +580,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
popup.StaysOpen = false;
}
//the popup explicitly gets the DataContext of this instance.
//If there is no DataContext, the TaskbarIcon assigns itself
if (popup != null)
{
UpdateDataContext(popup, null, DataContext);
}
//store a reference to the used tooltip
SetTrayPopupResolved(popup);
}