Listview containing items with foreign key

if your model has a FK property like this

public int FK { get; set; }

and FK points to a Widget object in List<Widget>, you could add a read-only property to your model like this

public string WidgetName 
    get {
      return Widgets.FirstOrDefault(w => w.ID == FK).Name;

then you can just use WidgetName in your binding

if you don’t want to modify your model, you could use the same approach in a ValueConverter that would convert FK into a Name, and use the converter in your binding

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top