C# - WPF - getting folder browser dialog without using System.Windows.Forms?
Asked Answered
P

4

12

I have this WPF app and I want to have there function of getting a directory path from the user. I would like to use some folder browser dialog but I don't want to implement it from System.Windows.Forms or use some huge script inside. Is there some path getting dialog in WPF already implemented?

I have read answers to similar questions here but it was full of System.Windows.Forms..

I haven't found anything like that in the Toolbox and I'm starting with WPF so I could use some help.

Thank you in advance :]

Pistil answered 30/4, 2013 at 16:17 Comment(7)
What's the problem with System.Windows.Forms (used from WPF) ?Grimsley
@HenkHolterman It just feels weird making WPF app so I wont make the Windows Form app and then use stuff from it there :|Pistil
You don't have to make a WinForms app... just borrow a few classes. There is no downside.Grimsley
@HenkHolterman I know, I know.. just thought that WPF will have covered the things that are in WinForms. Not to take them from there, but ok. Was just curious if it really isn't there somewhere and I just can't see it.Pistil
@goodfriend You are not alone on this. I always find it weird everytime I have to reference Windows forms to use the dialogs. I dont understand why WPF does not have their own? Plus I never really liked the FolderBrowserDialog to begin with.Wilkey
One concrete problem with the WinForms dialog is you can't parent it. We use parenting to enable programmatic dismissal of modal dialogs.Cai
Have you tried the Ookii Dialogs for WPF?Sunil
A
12

See my answer to Select folder dialog WPF. Basically the Windows Presentation Foundation 4.5 Cookbook recommends that you use the Windows® API Code Pack for Microsoft® .NET Framework if you need a folder browser.

Annamariaannamarie answered 18/7, 2013 at 1:29 Comment(1)
The Windows API Code Packs are available via Nuget here and here. This worked well for me.Polyzoan
E
8

we use Ookii Dialogs in our projects. They have the windows-look and feel and the typical options for filtering etc.

Encircle answered 30/4, 2013 at 16:21 Comment(1)
Here's a link to an updated Ookii Dialogs for WPF targetting .NET 4.5 and available on NuGetSunil
A
3

There are no standard native WPF dialogs for what you are looking for, simply because the System.Windows.Forms dialogs are nothing more than wrappers to the system ones. So creating a WPF wrapper makes no sense and will only add to the confusion.

Ahead answered 20/6, 2013 at 14:52 Comment(1)
No; what makes no sense is a UI framework which lacks such basic constructs. No folder browser dialog? No numeric updown? Give me a break.Shoifet
S
0

The Ookii Dialogs for WPF library has a VistaFolderBrowserDialog class that provides a complete implementation of a folder browser dialog for WPF.

https://github.com/augustoproiete/ookii-dialogs-wpf

Ookii Folder Browser Dialog

There's also a version compatible with Windows Forms apps

Sunil answered 4/10, 2018 at 3:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.