So I'm using FileSystemWatcher
to populate and update a playlist. I want to replicate many features of Windows Explorer, most importantly:
* inline rename
* slow double click to rename
I'm having quite a hassle doing this, so I thought, maybe there's an easier way than reimplementing the wheel? Maybe I can somehow host a Windows Explorer window in my application as a control?
Hosting a real Windows Explorer window in your application is possible but fraught with peril: The techniques are different in XP vs Vista vs Win7 and you will be dealing with all sorts of low-level stuff. I would strongly recommend against trying it.
I think your best options are:
Notes on inline rename feature
The inline rename and slow double-click to rename features are really quite trivial to implement.
In your view model add:
In your DataTemplate add a trigger on "Renaming" that replaces your TextBlock bound to "Name" with a TextBox bound to "NewName".
Add these event handlers: * KeyDown event: If F2 is pressed toggle Renaming. If Enter is pressed and Renaming, set Renaming=false. If Esc is pressed and Renaming copy Name to NewName and set Renaming=false. * LostFocus event: Set Renaming=false * SelectionChanged event on container: Record timestamp of last selection change. * MouseDown event: If left click and selection changed > 0.5 seconds ago, set Renaming = true
Many other features of Explorer view are similarly easy to implement, such as grouping and multiple columns.
Hope this helps.