我正在创建一个按ServiceName分组的 ListView ,但我无法显示FileName和FilePath,这里是类和 Xaml:
public class SOService
{
string _ServiceName;
List<SOFileInfo> _SOFiles;
public string ServiceName
{
get { return _ServiceName; }
set { _ServiceName = value; }
}
public List<SOFileInfo> SOFiles
{
get { return _SOFiles; }
set { _SOFiles = value; }
}
}
public class SOFileInfo
{
string _FileName;
string _FilePath;
public string FileName
{
get
{ return _FileName; }
set { _FileName = value; }
}
public string FilePath
{
get { return _FilePath; }
set { _FilePath = value; }
}
}
视图模型:
public class SOServiceViewModel
{
public SOServiceViewModel()
{
_Services = new List<SOService>();
_Services.Add(new SOService()
{
ServiceName = "service1",
SOFiles = new List<SOFileInfo>() { new SOFileInfo() { FileName = "File1", FilePath = "c:" } }
});
}
List<SOService> _Services;
public List<SOService> Services
{
get { return _Services; }
set { _Services = value; }
}
}
和 Xaml: