O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Path Selection with a Common Dialog Box

The last item on our to-do list is allowing the user to change the path of the picture files. WPF itself doesn’t have built-in dialog box classes to manage this, but the System.Windows.Forms namespace has just what we need: the FolderBrowserDialog class. This is launched from within the event handler for our FolderOpenMenuItem Click event.

private void FolderOpenMenuItem_Click(object sender, RoutedEventArgs e){   SetPath();}private void SetPath(){   FolderBrowserDialog dlg = new FolderBrowserDialog();   dlg.ShowDialog();   _path = dlg.SelectedPath;   ResetList();}

When a user selects a folder, we update our internal field appropriately, reload the DirectoryImageList class with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required