2012-03-23 69 views
0

任何人都可以請幫我把這段代碼轉換到vb.net,我曾與轉換器試了一下,但是編譯器給我的錯誤:C#來vb.net代碼(WPF,全局熱鍵implemetation)

HotKey hotkey = new HotKey((HwndSource)HwndSource.FromVisual(App.Current.MainWindow)); 
hotkey.Modifiers = HotKey.ModifierKeys.Alt | HotKey.ModifierKeys.Control; 
hotkey.Key = System.Windows.Input.Key.V; 
hotkey.HotKeyPressed += hotkey_HotKeyPressed; 

這是一篇關於WPF全局熱鍵的優秀文章,它可以在這裏找到http://www.codeproject.com/Tips/274003/Global-Hotkeys-in-WPF,但它在C#中,我的代碼在vb.net。

我得到這個從翻譯

Dim hotkey__1 As New HotKey(DirectCast(HwndSource.FromVisual(App.Current.MainWindow), HwndSource)) 
hotkey__1.Modifiers = HotKey.ModifierKeys.Alt Or HotKey.ModifierKeys.Control 
hotkey__1.Key = System.Windows.Input.Key.V 
hotkey__1.HotKeyPressed += hotkey_HotKeyPressed 

最後一行給我,我應該使用的RaiseEvent錯誤。有人能給我提示如何正確地轉換它嗎?

非常感謝!

回答

1

MSDN

AddHandler hotkey__1.HotKeyPressed, AddressOf hotkey_HotKeyPressed