c# - WPF Bind to derived object property -


i have abstract class vehicle, , 3 concrete class inherited i.e.boat, car , aeroplane.

now have collection of object has id, quantity , vehicle

class data {     public int id {get; set}     public int quantity {get; set;}     public vehicle vehicle {get; set;} } 

now have collection of data i.e. ienumerable<data> in viewmodel

and binding datagrid.

now properties car object might have aeroplane , boat object might not have , vice versa.

how can identify concrete object there in collection , accordingly show in description column.

for car want show data property review. aeroplane want show data property notes , boat.

all above property data should come in "description" column of datagrid

can please help?

add abstract description property vehicle class, , make sure classes inherit class put proper information in that. ui have consistent bind to.

abstract class vehicle {     public abstract string description { get; } }  class aeroplane : vehicle {     public string notes { get; set; }     public override string description => notes; }  class car : vehicle {     public string review { get; set; }     public override string description => review; }  class boat : vehicle {     public string notes { get; set; }     public override string description => notes; } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -