In Practice: Interoperability with the FolderBrowseDialog Control

WPF still doesn’t offer a counterpart for the FolderBrowseDialog control in Windows Forms, so let’s create one. Follow these steps:

1. Create a new project of type WPF User Control.

2. Add references to System.Windows.Forms.dll and WindowsFormsIntegration.dll.

3. Add a new code file called WpfFolderBrowseDialog, which is where you write custom code.

Now let’s start thinking in a WPF-oriented way. Since the original FolderBrowseDialog control from Windows Forms has its own properties (such as SelectedPath or Description), it can be interesting to expose them to the external world so that users can use information sent by the control, or set its properties. Since the value of these ...

Get Hidden WPF: Secrets for Creating Great Applications in Windows Presentation Foundation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.