How to use a FolderBrowserDialog from a WPF application

前端 未结 10 2059
青春惊慌失措
青春惊慌失措 2020-12-02 10:29

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.

However, when I call

10条回答
  •  萌比男神i
    2020-12-02 11:03

    VB.net translation

    Module MyWpfExtensions
    
    Public Function GetIWin32Window(this As Object, visual As System.Windows.Media.Visual) As System.Windows.Forms.IWin32Window
    
        Dim source As System.Windows.Interop.HwndSource = System.Windows.PresentationSource.FromVisual(Visual)
        Dim win As System.Windows.Forms.IWin32Window = New OldWindow(source.Handle)
        Return win
    End Function
    
    Private Class OldWindow
        Implements System.Windows.Forms.IWin32Window
    
        Public Sub New(handle As System.IntPtr)
            _handle = handle
        End Sub
    
    
        Dim _handle As System.IntPtr
        Public ReadOnly Property Handle As IntPtr Implements Forms.IWin32Window.Handle
            Get
    
            End Get
        End Property
    
    
    End Class
    
    End Module
    

提交回复
热议问题