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

@@ -27,7 +27,6 @@ using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Resources;
@@ -263,10 +262,18 @@ namespace Hardcodet.Wpf.TaskbarNotification
/// <param name="command">The command to be executed, or a null reference.</param>
/// <param name="commandParameter">An optional parameter that is associated with
/// the command.</param>
public static void ExecuteIfEnabled(this ICommand command, object commandParameter)
/// <param name="target">The target element on which to raise the command.</param>
public static void ExecuteIfEnabled(this ICommand command, object commandParameter, IInputElement target)
{
if (command == null) return;
if (command.CanExecute(commandParameter))
RoutedCommand rc = command as RoutedCommand;
if (rc != null)
{
//routed commands work on a target
if (rc.CanExecute(commandParameter, target)) rc.Execute(commandParameter, target);
}
else if (command.CanExecute(commandParameter))
{
command.Execute(commandParameter);
}