public Window1() { InitializeComponent(); DbOperations dbo = new DbOperations(); Dictionary <int, string> departments = dbo.getDepartments(); foreach (var d in departments) { ListBoxItem lbi = new ListBoxItem(); lbi.Content = d.Value; lbi.Uid = d.Key.ToString(); statementsListBox.Items.Add(lbi); } }