public SmileyWindow(Smiley smileyclass) { InitializeComponent(); Hashtable smileys = smileyclass.getAllSmileys(); List<MyData> smilieData = new List<MyData>(); foreach (var element in smileys.Keys) { smilieData.Add(new MyData() { code = (string)element, image = new Uri("pack://application:,,,/Smileys/" + (string)smileys[element]) } ); } // add separator //smilieData.Add(new MyData() {code = "Custom Smileys"}); smileyGrid.DataContext = smilieData; }