xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="200" Width="300"
Loaded="Window_Loaded">
One Million Numbers:
//File:Window.xaml.cs
using System.Windows;
using System.Windows.Threading;
using System.Collections.Generic;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Background,new LoadNumbersDelegate(LoadNumbers));
}
private delegate void LoadNumbersDelegate();
private void LoadNumbers()
{
List numberDescriptions = new List();
for(int i = 1; i <= 1000000; i++)
{
numberDescriptions.Add("Number " + i.ToString());
}
listBox.ItemsSource = numberDescriptions;
}
}
}