1

I try to use WPF NotifyIcon from here : Link

I created a taskbarIcon like this.

        TaskbarIcon tbi = new TaskbarIcon();
        tbi.DoubleClickCommand =

I want to add a function to DoubleClickCommand. It seems like it needs a ICommand. How can i do this in code-behind?

Trax
  • 943
  • 2
  • 12
  • 30

2 Answers2

2

You can create your own commands as here and then assign as

tbi.DoubleClickCommand = YourCreatedCommand;

You can also refer to : here for more information

Community
  • 1
  • 1
adityaswami89
  • 573
  • 6
  • 15
0
//This is command defining 
private ICommand myCommand; 

public ICommand MyCommand
{
   get
   {
      if (myCommand== null)
         myCommand= new RelayCommand(MyMethod);
      return myCommand;
   }
   set { myCommand= value; }
}


  //This is your command method
  public void MyMethod()
  {
  }

  //This is your xaml
  <Button Command="{Binding MyCommand}"/>

If you need parameter for pass to method;

myCommand= new RelayCommand<object>(MyMethod);//Change here like this;

And Change the XAML like this

//You can pass string parameter
<Button Command="{Binding MyCommand}" CommandParameter="MyParameter"/>        
Or
//You can pass a property
<Button Command="{Binding MyCommand}" CommandParameter="{Binding MyProperty}"/>
Aykut Demirci
  • 168
  • 4
  • 19