WPF NotifyIcon

--------------
FIX   Commands did not work with RoutedCommands which require an explicit target.
ADD   Added command target properties for both left and double click commands.
      Allows to explicitly define another control as the target of a routed
      command.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@112 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-07-02 11:18:13 +00:00
parent d6fe6cbf76
commit f4a1888e80
7 changed files with 114 additions and 16 deletions

View File

@@ -712,6 +712,32 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
#region DoubleClickCommandTarget dependency property
/// <summary>
/// The target of the command that is fired if the notify icon is double clicked.
/// </summary>
public static readonly DependencyProperty DoubleClickCommandTargetProperty =
DependencyProperty.Register("DoubleClickCommandTarget",
typeof (IInputElement),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(null));
/// <summary>
/// A property wrapper for the <see cref="DoubleClickCommandTargetProperty"/>
/// dependency property:<br/>
/// The target of the command that is fired if the notify icon is double clicked.
/// </summary>
public IInputElement DoubleClickCommandTarget
{
get { return (IInputElement) GetValue(DoubleClickCommandTargetProperty); }
set { SetValue(DoubleClickCommandTargetProperty, value); }
}
#endregion
#region LeftClickCommand dependency property
/// <summary>
@@ -762,6 +788,31 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
#region LeftClickCommandTarget dependency property
/// <summary>
/// The target of the command that is fired if the notify icon is clicked.
/// </summary>
public static readonly DependencyProperty LeftClickCommandTargetProperty =
DependencyProperty.Register("LeftClickCommandTarget",
typeof (IInputElement),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(null));
/// <summary>
/// A property wrapper for the <see cref="LeftClickCommandTargetProperty"/>
/// dependency property:<br/>
/// The target of the command that is fired if the notify icon is clicked.
/// </summary>
public IInputElement LeftClickCommandTarget
{
get { return (IInputElement) GetValue(LeftClickCommandTargetProperty); }
set { SetValue(LeftClickCommandTargetProperty, value); }
}
#endregion
//EVENTS
@@ -1038,7 +1089,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
protected RoutedEventArgs RaiseTrayMouseDoubleClickEvent()
{
RoutedEventArgs args = RaiseTrayMouseDoubleClickEvent(this);
DoubleClickCommand.ExecuteIfEnabled(DoubleClickCommandParameter);
DoubleClickCommand.ExecuteIfEnabled(DoubleClickCommandParameter, DoubleClickCommandTarget ?? this);
return args;
}