TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
lynn osler
NA
25
5.2k
Drag n Drop files into listbox but not duplicate files?
Aug 3 2011 12:38 PM
I am building a drag and drop that will drag a file into a listbox and "tooltip" the file location. Right now, I am trying to get it so that if the file is already there, it won't add it, but give a pop up saying it is there. Here is my code.
public
partial
class
MainWindow
:
Window
{
public
{
InitializeComponent();
}
MainWindow()
public
MainWindow()
private
void
filesDropped(
object
sender,
DragEventArgs
e)
if
(e.Data.GetDataPresent(
DataFormats
.FileDrop))
{
string
[] droppedFilePaths = e.Data.GetData(
DataFormats
.FileDrop,
true
)
as
string
[];
foreach
(
string
droppedFilePath
in
droppedFilePaths)
{
ListBoxItem
fileItem =
new
ListBoxItem
();
fileItem.Content = System.IO.
Path
.GetFileNameWithoutExtension(droppedFilePath);
fileItem.ToolTip = droppedFilePath;
DropListBox.Items.Add(fileItem);
}
}
Reply
Answers (
8
)
Customized TextBlock in WPF
Hardware acceleration in WPF