© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
59 replies
__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; }
}
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>
List<Foo>
where
FooA
FooA
s and
FooB
FooB
s would be displayed completely differently.

Just as a random example,
FooA
FooA
would simply display "This is a FooA" with a red background while
FooB
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
FooA
and
FooB
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Question about Avalonia
C#CC# / help
2y ago
Question regarding tasks
C#CC# / help
2y ago
✅ Question regarding EntityFramework
C#CC# / help
3y ago
Basic C# question
C#CC# / help
5mo ago