Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何与子对象进行数据绑定?_C#_Wpf_Xaml_Data Binding - Fatal编程技术网

C# 如何与子对象进行数据绑定?

C# 如何与子对象进行数据绑定?,c#,wpf,xaml,data-binding,C#,Wpf,Xaml,Data Binding,我有三节课,看起来像这样: 父类: public class Artist { public string name { get; set; } public List<Album> Albums { get; set; } public string Biography { get; set; } } 公共类艺术家 { 公共字符串名称{get;set;} 公共列表相册{get;set;} 公共字符串{get;set;} } 中产阶级: public cl

我有三节课,看起来像这样:

父类:

public class Artist
{
    public string name { get; set; }
    public List<Album> Albums { get; set; }
    public string Biography { get; set; }
}
公共类艺术家
{
公共字符串名称{get;set;}
公共列表相册{get;set;}
公共字符串{get;set;}
}
中产阶级:

public class Album
{
    public string name { get; set; }
    public int year { get; set; }
    public List<Artist> artists { get; set; }
    public List<Track> Tracks { get; set; }
}
公共类相册
{
公共字符串名称{get;set;}
公共整数年{get;set;}
公开列表艺术家{get;set;}
公共列表轨道{get;set;}
}
儿童班:

public class Track
{
    public string name { get; set; }
    public int year { get; set; }
    public Int64 duration { get; set; }
    public List<string> genre { get; set; }
    public string searchpath { get; set; }
    public Album album { get; set; }

}
公共类曲目
{
公共字符串名称{get;set;}
公共整数年{get;set;}
公共Int64持续时间{get;set;}
公共列表类型{get;set;}
公共字符串搜索路径{get;set;}
公共相册相册{get;set;}
}
如您所见,艺术家对象有一个专辑列表,而专辑对象有一个曲目列表

如果我有一个曲目列表(其中引用了它的父母),如果我想要一些带有艺术家姓名、专辑名称和曲目标题的文本块,我该如何将它与Listview绑定


有没有办法在绑定中执行
{Binding Path=track.album.name}
。如果将DataContext设置为曲目对象,则可以使用路径“album.name”绑定曲目的相册。

是否有任何方法在绑定中执行{Binding path=Track.album.name}?
是。在发布这个问题之前你试过吗?我试过了,是的。当我尝试它时遇到了一些异常,我想这就是原因。我得多看看我的代码。。很抱歉