0

I have a ListView that contains all images of the .jpg format from a given directory. It's filled by the codebehind using the following code:

DirectoryInfo folder = new DirectoryInfo(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + App.putanjaSlika);
FileInfo[] images = folder.GetFiles("*.jpg");
for (int i = 0; i<images.Length; ++i)
{
    FileInfo img = images[i];
    Thumbnails.Items.Add(new BitmapImage(new Uri(img.FullName)));
}

This works marvelously, but as you can see, the path is pretty much set in stone. What I need is some sort of a BrowseDirectoryDialog that can allow me to "open" a given directory, and use the located path as the argument for the first line of the above code.

I've found this question Open directory dialog and I like the Ookii.Dialogs solution, but perhaps even more the solution under the second answer. However, seeing as how that thread is 3.5 years old, I wanted to ask if a better solution came out, since I wasn't able to find any.

Community
  • 1
  • 1
NLuburić
  • 912
  • 1
  • 10
  • 28

2 Answers2

1

Unfortunately there is no dialogs of WPF. So you have to use Winforms.

Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
  • This always bugged me as well. The thought was WPF shouldn't have traditional pop up dialogs (that is a winforms approach). That being said they should have had some type of embedded control that would do the same thing so you could place it on a popout screen or some type of slider. – tsells Jun 01 '13 at 12:01
1

I published this folder browser dialog for WPF in 2011:

http://wpffolderbrowser.codeplex.com/

It is based on an MSDN example and full source code is provided, so you can adapt it as needed. I like it better than the solution mentioned in the linked post, because it displays the "new style" open folder dialog with Vista / Windows 7 look and feel, as opposed to the WinForms dialog which seems to be the same as in Windows 95.

hbarck
  • 2,934
  • 13
  • 16