From ef0689ec4e534261545adeae3f43295b96622f56 Mon Sep 17 00:00:00 2001 From: neuecc Date: Fri, 13 Aug 2021 18:35:45 +0900 Subject: [PATCH] WPF --- sandbox/WpfApp/MainWindow.xaml | 8 ++++++++ sandbox/WpfApp/MainWindow.xaml.cs | 28 +++++++++++++++++++++++++++- sandbox/WpfApp/WpfApp.csproj | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/sandbox/WpfApp/MainWindow.xaml b/sandbox/WpfApp/MainWindow.xaml index 4b92710..a9a07e9 100644 --- a/sandbox/WpfApp/MainWindow.xaml +++ b/sandbox/WpfApp/MainWindow.xaml @@ -7,6 +7,14 @@ mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> + + + + + + + + diff --git a/sandbox/WpfApp/MainWindow.xaml.cs b/sandbox/WpfApp/MainWindow.xaml.cs index 3befea9..38ab9bf 100644 --- a/sandbox/WpfApp/MainWindow.xaml.cs +++ b/sandbox/WpfApp/MainWindow.xaml.cs @@ -1,7 +1,9 @@ -using System; +using ObservableCollections; +using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -20,9 +22,33 @@ namespace WpfApp /// public partial class MainWindow : Window { + ObservableList list; + public ISynchronizedView ItemsView { get; set; } + public MainWindow() { InitializeComponent(); + this.DataContext = this; + + + + + list = new ObservableList(); + list.AddRange(new[] { 1, 10, 188 }); + ItemsView = list.CreateSortedView(x => x, x => x, comparer: Comparer.Default).WithINotifyCollectionChanged(); + + + BindingOperations.EnableCollectionSynchronization(ItemsView, new object()); + } + + int adder = 99; + + private void Button_Click(object sender, RoutedEventArgs e) + { + ThreadPool.QueueUserWorkItem(_ => + { + list.Add(adder++); + }); } } } diff --git a/sandbox/WpfApp/WpfApp.csproj b/sandbox/WpfApp/WpfApp.csproj index 4106cb0..d394da3 100644 --- a/sandbox/WpfApp/WpfApp.csproj +++ b/sandbox/WpfApp/WpfApp.csproj @@ -7,4 +7,8 @@ true + + + +