title: WPF converter and dictionary
body: <p>How do you properly implement a IValueConverter if you have a dictionary populated in another class?</p>
  
  <p>I'm sure i'm doing something wrong here but to explain my problem properly, here are the code supporting the question.</p>
  
  <p>iPresenter_IconLists.cs</p>
  
  <pre><code>public interface iPresenter_IconLists
  {
      Dictionary&lt;string, IconPositionDetails&gt; IconDetails { get; set; }
  }
  </code></pre>
  
  <p>Presenter_IconLists.cs</p>
  
  <pre><code>public class Presenter_IconLists : iPresenter_IconLists, IValueConverter
  {
      public Presenter_IconLists()
      {
  
      }
  
      public void PopulateDictionaryTest()
      {
          this.IconDetails.Add("test1", new IconPositionDetails()
          {
              x = 0,
              y = 0
          });
          this.IconDetails.Add("test2", new IconPositionDetails()
          {
              x = 0,
              y = 0
          });
          this.IconDetails.Add("test3", new IconPositionDetails()
          {
              x = 0,
              y = 0
          });
      }
  
      Dictionary&lt;string, IconPositionDetails&gt; _IconDetails = new Dictionary&lt;string, IconPositionDetails&gt;();
      public Dictionary&lt;string, IconPositionDetails&gt; IconDetails
      {
          get { return this._IconDetails; }
          set { this._IconDetails = value; }
      }
  
      // IValueConverter implementation
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          iPresenter_IconLists i = this;
  
          IconPositionDetails ipd = i.IconDetails[value.ToString()];
          // or
          // IconPositionDetails ipd = this.IconDetails[value.ToString()];
  
          return string.Format("x: {0}, y: {1}", ipd.x, ipd.y);
      }
  }
  </code></pre>
  
  <p>MainWindow.xaml</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;l:Presenter_IconLists x:Key="DictConvert" x:Name="DictConvert" /&gt;
  
      &lt;TextBlock Text="{Binding Converter={StaticResource DictConvert}, ConverterParameter=Value.x}" Height="28" HorizontalAlignment="Left" Margin="60,49,0,0" VerticalAlignment="Top" FontSize="11" /&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>MainWindow.xaml.cs</p>
  
  <pre><code>Presenter_IconLists iconlists;
  void MainWindow_Loaded(object sender, RoutedEventArgs e)
  {
      this.iconlists = new Presenter_IconLists();
      this.iconlists.PopulateDictionaryTest();
  
      lbIcons.ItemsSource = this.iconlists.IconDetails;
  }
  </code></pre>
  
  <p>the problem here is, I always getting "The given key was not present in the dictionary." and when I check the this.IconDetails number of collection, it was zero.</p>
  
  <p>How do I access my dictionary inside the Converter?</p>