/* * Generate customers, pass data to grid, and create host control */ private void Window_Loaded(object sender, RoutedEventArgs e) { app = System.Windows.Application.Current; myWindow = app.MainWindow; List <Customer> customers = new List <Customer>(); for (int i = 0; i < customerFirstNames.Length; i++) { string id = new string(Enumerable.Repeat(chars, 12).Select(s => s[random.Next(s.Length)]).ToArray()); customers.Add(new Customer(id, customerFirstNames[i], customerLastNames[random.Next(0, customerLastNames.Length - 1)], GenerateRandomDay(), random.NextDouble() >= 0.5, GenerateRandomData())); } CustomerGrid.ItemsSource = customers; listControl = new ControlHost(ControlHostElement.ActualHeight, ControlHostElement.ActualWidth, this.CurrentDPI); ControlHostElement.Child = listControl; }