C#C
C#3y ago
__dil__

❔ [Avalonia] Basic question regarding subclassing

Let's say I have some types like so:
public abstract class Foo {}

public class FooA: Foo {}

public class FooB: Foo
{
  public string Name { get; }
  public int age { get; }
}


I'd like to display a List<Foo> where FooAs and FooBs would be displayed completely differently.

Just as a random example, FooA would simply display "This is a FooA" with a red background while FooB would display "This is a FooB with name '...' and age '...' " in a blue background. You get the idea.

The way I envision this is that FooA and FooB would themselves define how they should be displayed.

I would be really grateful if someone could break this down to me. Bonus points if there's a working example.
Was this page helpful?