[英]C# WPF NotifyIcon BalloonTip and the TrayBalloonTipClicked Event
[英]C# Wpf How to Add DoubleClick Function to “WPF NotifyIcon”
我嘗試從此處使用WPF NotifyIcon: 鏈接
我創建了一個像這樣的taskbarIcon。
TaskbarIcon tbi = new TaskbarIcon();
tbi.DoubleClickCommand =
我想向DoubleClickCommand添加一個功能。 似乎需要ICommand。 我該如何在后台代碼中執行此操作?
//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}"/>
如果需要參數傳遞給方法;
myCommand= new RelayCommand<object>(MyMethod);//Change here like this;
並像這樣更改XAML
//You can pass string parameter
<Button Command="{Binding MyCommand}" CommandParameter="MyParameter"/>
Or
//You can pass a property
<Button Command="{Binding MyCommand}" CommandParameter="{Binding MyProperty}"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.