3
我将我的Listbox绑定到了我的BindableCollection,但我只想显示文件名。目前,它显示 “DTO”在WPF中绑定DTO
public class FilesDTO : IDTO
{
public int Id { get; set; }
public string FileName { get; set; }
public string FileExtension { get; set; }
public byte[] FileArray { get; set; }
}
using (var ctx = DB.Get())
{
Files = new BindableCollection<FilesDTO>(ctx.Files.Select(x => new FilesDTO { FileArray = x. FileArray, FileExtension = x.FileExtension, FileName = x.FileName, Id = x.Id }));
}
的XAML的一面:
<ListBox x:Name="Attachments" Grid.Row="2" ItemsSource="{Binding Files}" />
我试过{结合Files.Filename}也不起作用。我的猜测是创建要绑定的属性:S