<ListBox x:Name="ListBoxFiles"
ItemsSource="{Binding Files}"
AllowDrop="True"
SelectionMode="Single"
DragEnter="ListBox_Files_DragEnterOverLeave"
DragOver="ListBox_Files_DragEnterOverLeave"
DragLeave="ListBox_Files_DragEnterOverLeave"
Drop="ListBox_Files_Drop"
MouseLeftButtonUp="ListBoxFiles_MouseLeftButtonUp"
MouseDoubleClick="ListBox_Files_MouseDoubleClick">
</ListBox>
private void ListBox_Files_DragEnterOverLeave( object sender, DragEventArgs e )
{
if( GetWindowLogic<mainwindowlogic>().ValidProjectsDirectory && e.Data.GetDataPresent( DataFormats.FileDrop ) )
{
QA.LogTrace( $"Got a valid directory and data in event handler." );
e.Effects = DragDropEffects.Copy;
}
else
{
QA.LogTrace( $"Either a valid directory or data is absent in event handler." );
e.Effects = DragDropEffects.None;
e.Handled = true;
}
}