|
|
@@ -4,10 +4,10 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Reactive;
|
|
|
using Avalonia.Collections;
|
|
|
using Avalonia.Controls;
|
|
|
using Avalonia.Controls.Primitives;
|
|
|
-using ReactiveUI.Legacy;
|
|
|
using ReactiveUI;
|
|
|
using Avalonia.Layout;
|
|
|
|
|
|
@@ -18,7 +18,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
private int _itemCount = 200;
|
|
|
private string _newItemString = "New Item";
|
|
|
private int _newItemIndex;
|
|
|
- private IReactiveList<ItemViewModel> _items;
|
|
|
+ private AvaloniaList<ItemViewModel> _items;
|
|
|
private string _prefix = "Item";
|
|
|
private ScrollBarVisibility _horizontalScrollBarVisibility = ScrollBarVisibility.Auto;
|
|
|
private ScrollBarVisibility _verticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
|
|
@@ -28,11 +28,12 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public MainWindowViewModel()
|
|
|
{
|
|
|
this.WhenAnyValue(x => x.ItemCount).Subscribe(ResizeItems);
|
|
|
- RecreateCommand = ReactiveCommand.Create(() => Recreate());
|
|
|
|
|
|
- AddItemCommand = ReactiveCommand.Create(() => AddItem());
|
|
|
+ RecreateCommand = ReactiveCommand.Create(Recreate);
|
|
|
|
|
|
- RemoveItemCommand = ReactiveCommand.Create(() => Remove());
|
|
|
+ AddItemCommand = ReactiveCommand.Create(AddItem);
|
|
|
+
|
|
|
+ RemoveItemCommand = ReactiveCommand.Create(Remove);
|
|
|
|
|
|
SelectFirstCommand = ReactiveCommand.Create(() => SelectItem(0));
|
|
|
|
|
|
@@ -54,7 +55,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public AvaloniaList<ItemViewModel> SelectedItems { get; }
|
|
|
= new AvaloniaList<ItemViewModel>();
|
|
|
|
|
|
- public IReactiveList<ItemViewModel> Items
|
|
|
+ public AvaloniaList<ItemViewModel> Items
|
|
|
{
|
|
|
get { return _items; }
|
|
|
private set { this.RaiseAndSetIfChanged(ref _items, value); }
|
|
|
@@ -93,11 +94,11 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public IEnumerable<ItemVirtualizationMode> VirtualizationModes =>
|
|
|
Enum.GetValues(typeof(ItemVirtualizationMode)).Cast<ItemVirtualizationMode>();
|
|
|
|
|
|
- public ReactiveCommand AddItemCommand { get; private set; }
|
|
|
- public ReactiveCommand RecreateCommand { get; private set; }
|
|
|
- public ReactiveCommand RemoveItemCommand { get; private set; }
|
|
|
- public ReactiveCommand SelectFirstCommand { get; private set; }
|
|
|
- public ReactiveCommand SelectLastCommand { get; private set; }
|
|
|
+ public ReactiveCommand<Unit, Unit> AddItemCommand { get; private set; }
|
|
|
+ public ReactiveCommand<Unit, Unit> RecreateCommand { get; private set; }
|
|
|
+ public ReactiveCommand<Unit, Unit> RemoveItemCommand { get; private set; }
|
|
|
+ public ReactiveCommand<Unit, Unit> SelectFirstCommand { get; private set; }
|
|
|
+ public ReactiveCommand<Unit, Unit> SelectLastCommand { get; private set; }
|
|
|
|
|
|
public void RandomizeSize()
|
|
|
{
|
|
|
@@ -123,7 +124,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
{
|
|
|
var items = Enumerable.Range(0, count)
|
|
|
.Select(x => new ItemViewModel(x));
|
|
|
- Items = new ReactiveList<ItemViewModel>(items);
|
|
|
+ Items = new AvaloniaList<ItemViewModel>(items);
|
|
|
}
|
|
|
else if (count > Items.Count)
|
|
|
{
|
|
|
@@ -162,7 +163,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
_prefix = _prefix == "Item" ? "Recreated" : "Item";
|
|
|
var items = Enumerable.Range(0, _itemCount)
|
|
|
.Select(x => new ItemViewModel(x, _prefix));
|
|
|
- Items = new ReactiveList<ItemViewModel>(items);
|
|
|
+ Items = new AvaloniaList<ItemViewModel>(items);
|
|
|
}
|
|
|
|
|
|
private void SelectItem(int index)
|