Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FolderBrowserDialog in wpf c#

I am using System.Windows; and System.Windows.Controls; so I can't use System.Windows.Forms; because there is a lot of controls like messagebox and list box...etc are common between them is there another solution to get folderbrowserdialog without using System.Windows.Forms; or is there any get folder location dialog box ?

like image 285
kartal Avatar asked Dec 21 '22 11:12

kartal


2 Answers

You can use the FolderBrowserDialog; either explicitly place the namespace in front of the class...

System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();

...or create an alias with regard to your namespace.

Imports [ aliasname = ] namespace
like image 112
Aaron McIver Avatar answered Dec 24 '22 02:12

Aaron McIver


I have also encountered this using FolderBrowserDialog in WPF with listBox.

because we use WPF, we need to add winform component "FolderBrowserDialog".

  • right click on the project name or reference, and choose "Add reference"
  • choose .Net tab and browse for System.Windows.Forms.

So now you can use FolderBrowserDialog in WPF.

private FolderBrowserDialog openFolder = new FolderBrowserDialog();

Here is a link to a post on my blog that contains the image and a short explanation http://syumulnetwork.blogspot.com/2011/09/myth-self-note-5-c-wpf.html

like image 20
condemnedemotion Avatar answered Dec 24 '22 02:12

condemnedemotion