我在 Visual Studio 中完全是菜鳥。我正在嘗試使用 WPF 撰寫一個簡單的應用程式。我需要一個可以選擇檔案夾的對話框。我知道 WPF 沒有,我需要使用 Windows.Forms他們的 FolderBrowserDialog。我需要將 Widnows.Forms 框架添加到參考中,以便我可以說 using System.Windows.Forms;然后執行此對話框。但是,當我嘗試按照說明進行操作時,我在這里看不到任何 Windows.Forms,除了正在播放的內容影像。即使我添加了這些,它仍然不需要using System.Windows.Forms;
我該怎么辦?

uj5u.com熱心網友回復:
- 首先創建一個.Net6 Wpf專案
- 雙擊工程進入csproj,手動添加如下代碼:
<UseWindowsForms>true</UseWindowsForms>

- 手動輸入以下新建
- 叫它
private void Button_Click(object sender, RoutedEventArgs e) { using FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); { folderBrowserDialog.ShowDialog(); } }- 你也可以在.net6專案中去
Property->Application->General->Windows Forms-> 。Enable Windows Forms for this Project

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/494716.html
