原本此类是 http://www.codeproject.com 上高手写的 ShellContextMenu 类
但是该类原本貌似是为 WinForm 设计的 , 默认的命名空间和引用也是 WinForm 的
但是最近有需求要让 WPF 也能使用该类所实现的功能 ! 然后实践中发现 WPF 也能使用, 不过就是要在 WPF 中引用该类用到的 WinForm 命名空间就行了
具体的请看 示例 Demo 下载: http://download.csdn.net/detail/herluckily/9578026
/// <summary>
/// ShellContextMenu 文件夹右键菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, RoutedEventArgs e)
{
ShellContextMenu scm = new ShellContextMenu();
string fileName = @"D:\Test\测试文件夹";
DirectoryInfo[] folders = new DirectoryInfo[1];
folders[0] = new DirectoryInfo(fileName);
scm.ShowContextMenu(folders, System.Windows.Forms.Cursor.Position);
}
/// <summary>
/// ShellContextMenu 文件右键菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, RoutedEventArgs e)
{
Peter.ShellContextMenu scm = new Peter.ShellContextMenu();
FileInfo[] files = new FileInfo[1];
string fileName = @"D:\Test\测试文本文档.txt";
files[0] = new FileInfo(fileName);
scm.ShowContextMenu(files, System.Windows.Forms.Cursor.Position);
}
示例 Demo 下载: http://download.csdn.net/detail/herluckily/9578026