How to use a FolderBrowserDialog from a WPF application with MVVM

Posted by David Work on Stack Overflow See other posts from Stack Overflow or by David Work
Published on 2012-09-05T20:16:57Z Indexed on 2012/09/05 21:38 UTC
Read the original article Hit count: 1900

Filed under:
|
|
|
|

I'm trying to use the FolderBrowserDialog from my WPF application - nothing fancy. I don't much care that it has the Windows Forms look to it.

I found a question with a suitable answer (How to use a FolderBrowserDialog from a WPF application), except I'm using MVVM.

This was the answer I "implemented", except I can't get the window object and I'm just calling ShowDialog() without any parameters.

The problem is this:

var dlg = new FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dlg.ShowDialog(this.GetIWin32Window());

In my ViewModel there the this has no GetIWin32Window() method for me to get the Window context.

Any ideas on how to make this work?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET