WPF Check
This commit is contained in:
parent
f5bf911c82
commit
170eecf922
@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:WpfApp"
|
xmlns:local="clr-namespace:WpfApp"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid>
|
<!--<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
@ -16,5 +16,9 @@
|
|||||||
|
|
||||||
<Button Grid.Column="1" Click="Button_Click">Insert</Button>
|
<Button Grid.Column="1" Click="Button_Click">Insert</Button>
|
||||||
|
|
||||||
</Grid>
|
</Grid>-->
|
||||||
|
<StackPanel>
|
||||||
|
<ListBox ItemsSource="{Binding ItemsView}" />
|
||||||
|
<Button Content="Clear" Command="{Binding ClearCommand}" />
|
||||||
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using ObservableCollections;
|
using ObservableCollections;
|
||||||
|
using R3;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -22,38 +24,72 @@ namespace WpfApp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
ObservableList<int> list;
|
//ObservableList<int> list;
|
||||||
public INotifyCollectionChangedSynchronizedView<int> ItemsView { get; set; }
|
//public INotifyCollectionChangedSynchronizedView<int> ItemsView { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.DataContext = this;
|
|
||||||
|
|
||||||
|
R3.WpfProviderInitializer.SetDefaultObservableSystem(x =>
|
||||||
|
{
|
||||||
|
Trace.WriteLine(x);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.DataContext = new ViewModel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list = new ObservableList<int>();
|
//list = new ObservableList<int>();
|
||||||
list.AddRange(new[] { 1, 10, 188 });
|
//list.AddRange(new[] { 1, 10, 188 });
|
||||||
ItemsView = list.CreateSortedView(x => x, x => x, comparer: Comparer<int>.Default).ToNotifyCollectionChanged();
|
//ItemsView = list.CreateSortedView(x => x, x => x, comparer: Comparer<int>.Default).ToNotifyCollectionChanged();
|
||||||
|
|
||||||
|
|
||||||
|
//BindingOperations.EnableCollectionSynchronization(ItemsView, new object());
|
||||||
|
}
|
||||||
|
|
||||||
|
//int adder = 99;
|
||||||
|
|
||||||
|
//private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
//{
|
||||||
|
// ThreadPool.QueueUserWorkItem(_ =>
|
||||||
|
// {
|
||||||
|
// list.Add(adder++);
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
|
||||||
|
//protected override void OnClosed(EventArgs e)
|
||||||
|
//{
|
||||||
|
// ItemsView.Dispose();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewModel
|
||||||
|
{
|
||||||
|
private ObservableList<int> observableList { get; } = new ObservableList<int>();
|
||||||
|
public INotifyCollectionChangedSynchronizedView<int> ItemsView { get; }
|
||||||
|
public ReactiveCommand<Unit> ClearCommand { get; } = new ReactiveCommand<Unit>();
|
||||||
|
|
||||||
|
public ViewModel()
|
||||||
|
{
|
||||||
|
observableList.Add(1);
|
||||||
|
observableList.Add(2);
|
||||||
|
|
||||||
|
ItemsView = observableList.CreateView(x => x).ToNotifyCollectionChanged();
|
||||||
|
|
||||||
BindingOperations.EnableCollectionSynchronization(ItemsView, new object());
|
BindingOperations.EnableCollectionSynchronization(ItemsView, new object());
|
||||||
}
|
|
||||||
|
|
||||||
int adder = 99;
|
// var iii = 10;
|
||||||
|
ClearCommand.Subscribe(_ =>
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ThreadPool.QueueUserWorkItem(_ =>
|
|
||||||
{
|
{
|
||||||
list.Add(adder++);
|
// observableList.Add(iii++);
|
||||||
|
observableList.Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosed(EventArgs e)
|
|
||||||
{
|
|
||||||
ItemsView.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,10 @@
|
|||||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="R3Extensions.WPF" Version="1.0.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\ObservableCollections\ObservableCollections.csproj" />
|
<ProjectReference Include="..\..\src\ObservableCollections\ObservableCollections.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user