我正在使用 MVVM 加载文本文件并显示它们的内容。
模型
MyFile.cs有一个Name和Text// 实现 INotifyPropertyChanged
MyFileRepository.cs// 我加载的文件的集合
视图模型
OpenFileCommand加载文件并将其添加到 _filerepository 对象
FileCollection绑定到视图
看法
Button解雇OpenCommand
ComboBox显示加载文件的名称
TextBox在 combobx 中显示所选文件的内容
<Button Name="OpenFile" Command="{Binding OpenFileCommand}">
<ComboBox Name="FilesList" ItemsSource="{Binding Path=FileCollection}" DisplayMemberPath="Name" />
<TextBox Name="FileContent" Text="{Binding the Text of selected file in combobx "/>
如何将combobx中选择的MyFile的Text属性绑定到TextBox?