谁能告诉我如何使用 C# 和 WPF 在文本框中显示当前工作目录的路径?
我不明白如何绑定(bind)它。
最佳答案
ViewModel/View 的后台代码:
public string CurrentDirectoryPath { get { return Environment.CurrentDirectory; } }
在 View 的 XAML 中:
<TextBox Text="{Binding CurrentDirectoryPath}" />
设置正确的DataContext
// If you are using MVVM: var view = new MyView { DataContext = new MyViewModel() };
关于c# - 在 WPF 文本框中显示 "current working directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8715993/