public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { MegaWidget widget = value as MegaWidget; string location = (string)parameter; return(widget?.Locations[location]?.Contents); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { MegaWidget MWidget = (MegaWidget)value; Location loc = MWidget.Locations[(string)parameter]; //Refers to Class "Content" used in loc.Contents collection. I do not know what the name that you have used foreach (Content item in loc.Contents) { item.Name += "***"; } return(loc.Contents); }
public FooViewModel() { Widget = new MegaWidget { Locations = new Dictionary <string, Location> { ["Front"] = new Location { Contents = new List <Part> { new Part { Id = 1, PartName = "Part 01" }, new Part { Id = 2, PartName = "Part 02" }, new Part { Id = 3, PartName = "Part 03" }, } }, ["Back"] = new Location { Contents = new List <Part> { new Part { Id = 11, PartName = "Part 11" }, new Part { Id = 12, PartName = "Part 12" }, new Part { Id = 13, PartName = "Part 13" }, } }, } }; }