I really search the internet and could not find a answer.
Its hard for me to describe what i try to do. Maybe that is the reason i
could not find a answer on Stackoverflow and Google.
I have a ListBox in my Page which is bound to a ObservableCollection<Model>.
This Model has a property with a Id of another model. There is also
a Dictionary<int,SecondModel> containing the realted second models.
I could not add a property with the second model to the first model because this is a third party library.
Is it possible to get the Name property from the realated SecondModel using the collection?
Text="{Binding ???}"
Sample
public class Model
{
public int Id { get; set; }
public int SecondModelId { get; set; }
}
public class SecondModel
{
public int Id { get; set; }
public string Name { get; set; }
}
public class SomeOtherModel
{
public Dictionary<int,SecondModel> SecondModelCollection{ get; set; }
}
If you cannot play with the guts of
Modelclass, I ll suggest wrapping the two models in a something like:You can set the joinedCollection as the data source instead of the firstModelCollection which isgiven as
ObservableCollection<Model>in the question.Then in the binding, you can do a two level binding like
Text="{Binding SecondModel.Name}"… tho, I am assuming you can change the datasource of your view, I hope you can 🙂