WPF Converter to look up in generic list

Posted by user310046 on Stack Overflow See other posts from Stack Overflow or by user310046
Published on 2010-06-02T17:06:57Z Indexed on 2010/06/02 18:24 UTC
Read the original article Hit count: 180

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding