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