I have the below classes (abbreviated for simplicity):
namespace Test
{
class Class1
{
Class2 Property2 { get; set; }
Class3 Property3 { get; set; }
}
class Class2
{
string ColumnName { get; set; }
}
class Class3
{
string ColumnName { get; set; }
bool IsRequired { get; set; }
}
}
I instantiate a list of Class1 and populate it, then set the databinding of a ListView to my list as below.
List<Class1> pList = ...;
listView1.ItemsSource = pList;
I’ve tried to set listView1.DisplayMemberPath equal to "ColumnName", "Class2.ColumnName", "Class3.ColumnName", "Test.Class2.ColumnName", but nothing seems to work (the ListView displays blank items. If I set the DisplayMemberPath to a list of Class2 or Class3, the ListView displays, but I’d like to keep a list of Class1 as my
datasource.
Is there anything simple I’m missing here (I’m assuming this is very possible)? (I’ve searched far and wide for a solution to my problem (which is hopefully really simple), but I haven’t gotten anything to work yet.)
The name of your internal classes are Property2 and Property3,
so I think that the right use for listView1.DisplayMemberPath is: