using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private System.Collections.ObjectModel.ObservableCollection<string> Values;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Values = new System.Collections.ObjectModel.ObservableCollection<string>();
list.DataContext = Values;
System.Threading.Thread t = new System.Threading.Thread(ThreadDesuyo);
t.Start();
}
private void ThreadDesuyo()
{
for (int i = 0; i < 10; i++)
{
list.Dispatcher.BeginInvoke(new TestDelegate(TestMethod), i);
}
}
private delegate void TestDelegate(int i);
private void TestMethod(int i)
{
this.list.Items.Add(i.ToString());
System.Threading.Thread.Sleep(500);
}
}
}