Created
May 27, 2012 14:22
-
-
Save pinzolo/2814411 to your computer and use it in GitHub Desktop.
WPFでのファイル or ディレクトリのドラッグアンドドロップ処理
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// DragOver イベント処理 | |
/// </summary> | |
/// <param name="sender">イベント発生元</param> | |
/// <param name="e">イベント引数</param> | |
private void Window_DragOver(object sender, DragEventArgs e) | |
{ | |
if (e.Data.GetDataPresent(DataFormats.FileDrop)) | |
{ | |
e.Effects = DragDropEffects.Copy; | |
e.Handled = true; | |
} | |
else | |
{ | |
e.Effects = DragDropEffects.None; | |
} | |
} | |
/// <summary> | |
/// Drop イベント処理 | |
/// </summary> | |
/// <param name="sender">イベント発生元</param> | |
/// <param name="e">イベント引数</param> | |
private void Window_Drop(object sender, DragEventArgs e) | |
{ | |
var paths = e.Data.GetData(DataFormats.FileDrop) as String[]; | |
if (paths != null) | |
{ | |
// do something... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment