Focus Last item in FileList

FileExplorer includes two WPF controls, DirectoryTree and FileList.  Both support any normal/shell directory, background item loading, drag and drop, shell context menu, also refresh itself when the filesystem is changed.

FileList also support seven different viewmodes, sort using grid header, multi-select via dragging and able to update itself when the FileSystem is Changed.

I have updated FileExplorer to 0.5, with the following changes.

  • Fixed a bug related to expand wrong directory when expand via double click on file list.
  • Fixed a crash in DriveModel (Drive not found)
  • Added Select(), SelectAll(), UnselectAll() and Focus() method.

DirectoryInfoEx and FileExplorer is released under LGPL license.
You can download the control here, or read the article on CodeProject.

Please noted that the DirectoryInfoEx included is 0.17 and is not the newest version.

Issue

Normally, one would use ScrollIntoView() method to “Focus” the control,

this.ScrollIntoView(selectedVM);

But somehow it doesnt work on the VirtualWrapPanel, so I used some workaround :

VirtualWrapPanel vwp = UITools.FindVisualChild(this);
int idx = Items.IndexOf(selectedVM);
if (vwp != null && idx != -1)
{
  Rect rect = vwp.GetChildRect(idx);
  if (vwp.Orientation == Orientation.Horizontal)
     vwp.SetVerticalOffset(rect.Top);
  else vwp.SetHorizontalOffset(rect.Left);
}