【发布时间】:2019-06-06 14:47:07
【问题描述】:
我对这个任务有疑问。你能帮帮我吗?
class FileTAG
{
public FileInfo file;
}
我创建了一个 FileTAG 列表(它调用 checkTag),我想在 WPF 应用程序的数据网格中显示列表的每个节点中的所有数据内容。所以我这样做:
grd_lista.ItemsSource = checkTag;
但这就是出现的情况。
你能帮帮我吗?
【问题讨论】:
-
您的
FileTAG.file必须是一个属性。另见stackoverflow.com/questions/842575/… -
你能解释更多吗?我的 FileInfo 文件已经是 FileTAG 类的属性
-
FileTAG.file是一个字段而不是一个属性,你必须写public FileInfo File { get; set; }(最好使用PascalCasing。另见docs.microsoft.com/en-us/dotnet/standard/design-guidelines/…)。有关属性和字段的更多信息,请参阅 docs.microsoft.com/en-us/dotnet/csharp/properties / docs.microsoft.com/en-us/dotnet/csharp/programming-guide/… 和 stackoverflow.com/questions/295104/… -
好的,我将我的字段更改为属性。但这不会改变我在 DataGrid 上的可视化。我在我的类 FileTag 中添加了属性 nomeFile:
public string nomeFile { get; set;}在我的 dataGrid grd_lista 中出现一个新列,其长度为字符串但不是文本。 -
请将这些更改添加到您的问题中,并添加定义
DataGrid的 xaml 部分