2021-08-13 18:35:45 +09:00
|
|
|
|
using ObservableCollections;
|
|
|
|
|
using System;
|
2021-08-04 09:30:34 +09:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2021-08-13 18:35:45 +09:00
|
|
|
|
using System.Threading;
|
2021-08-04 09:30:34 +09:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
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 WpfApp
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2021-08-13 18:35:45 +09:00
|
|
|
|
ObservableList<int> list;
|
|
|
|
|
public ISynchronizedView<int, int> ItemsView { get; set; }
|
|
|
|
|
|
2021-08-04 09:30:34 +09:00
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2021-08-13 18:35:45 +09:00
|
|
|
|
this.DataContext = this;
|
|
|
|
|
|
2021-09-02 16:37:20 +09:00
|
|
|
|
|
2021-08-13 18:35:45 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list = new ObservableList<int>();
|
|
|
|
|
list.AddRange(new[] { 1, 10, 188 });
|
|
|
|
|
ItemsView = list.CreateSortedView(x => x, x => x, comparer: Comparer<int>.Default).WithINotifyCollectionChanged();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BindingOperations.EnableCollectionSynchronization(ItemsView, new object());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int adder = 99;
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ThreadPool.QueueUserWorkItem(_ =>
|
|
|
|
|
{
|
|
|
|
|
list.Add(adder++);
|
|
|
|
|
});
|
2021-08-04 09:30:34 +09:00
|
|
|
|
}
|
2021-09-03 18:14:01 +09:00
|
|
|
|
|
|
|
|
|
protected override void OnClosed(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ItemsView.Dispose();
|
|
|
|
|
}
|
2021-08-04 09:30:34 +09:00
|
|
|
|
}
|
|
|
|
|
}
|