WPF Converter to look up in generic list
- by user310046
I have a list of data where I keep e.g. countries with code, name and some other data.
List<Country> countries = <deserialized objects from file>
which consist of objects like this:
public class Country
{
public string Code { get; set;}
public string Name { get; set;}
}
The object which use as a DataContext may look like this:
public class Address
{
public string StreetName{ get; set;}
public string CountryCode { get; set;}
}
Then in my XAML I want to do something like this to show the name of the country
<TextBlock Text="{Binding Path=CountryCode, Converter={StaticResource CountryNameLookupConverter}}"/>
But how can I make the CountryNameLookupConverter use the countries list I read from the xml file?