How can I get an open folder dialog in WPF?

David Reinke 20 Reputation points
2023-11-29T23:38:21.7366667+00:00

I cannot find an OpenFolder dialog in WPF. I looked at the MS help, and it said to create a reference to Systems.Windows.Forms.dll. The only reference I could find is in the picture below. I added this to my WPF project. but when I tried to put in the following statement:

using System.Windows.Forms;

I gotan error message that this was an invalid reference. So it looks like it is impossible to create a reference to System.Windows.Forms in a WPF project. I'm rather annoyed at Microsoft for leaving a folder browser dialog out of the WPF tools. This is a serious defect.

And BTW, your help page is completely wrong, as I find it impossible to create a reference to System.Windows.Forms in a WPF project. I've tried this three times now, and I've given up.

Developer technologies | Windows Presentation Foundation
{count} votes

Answer accepted by question author
  1. RLWA32 51,361 Reputation points
    2023-11-30T01:10:05.0466667+00:00

    Assuming that you are using .Net and not .Net Framework -

    In project properties Application->General check "Enable Windows Forms for this project".

    EnableWinforms

    To eliminate ambiguity between System.Windows.Application and System.Windows.Forms.Application -

    App

    Button click to invoke dialog -

    click

    Result -

    result

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.