Select folder dialog WPF

后端 未结 10 707
暗喜
暗喜 2020-11-28 19:32

I develop a WPF4 application and in my app I need to let the user select a folder where the application will store something (files, generated reports etc.).

My requ

10条回答
  •  旧时难觅i
    2020-11-28 19:58

    Based on Oyun's answer, it's better to use a dependency property for the FolderName. This allows (for example) binding to sub-properties, which doesn't work in the original. Also, in my adjusted version, the dialog shows selects the initial folder.

    Usage in XAML:

    
    

    Code:

    using System.Windows;
    using System.Windows.Forms;
    using System.Windows.Interactivity;
    using Button = System.Windows.Controls.Button;
    
    public class FolderDialogBehavior : Behavior

提交回复
热议问题