|
@@ -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 AvaloniaList<ItemViewModel> _items;
|
|
|
+ private IReactiveList<ItemViewModel> _items;
|
|
|
private string _prefix = "Item";
|
|
|
private ScrollBarVisibility _horizontalScrollBarVisibility = ScrollBarVisibility.Auto;
|
|
|
private ScrollBarVisibility _verticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
|
@@ -28,12 +28,11 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public MainWindowViewModel()
|
|
|
{
|
|
|
this.WhenAnyValue(x => x.ItemCount).Subscribe(ResizeItems);
|
|
|
+ RecreateCommand = ReactiveCommand.Create(() => Recreate());
|
|
|
|
|
|
- RecreateCommand = ReactiveCommand.Create(Recreate);
|
|
|
+ AddItemCommand = ReactiveCommand.Create(() => AddItem());
|
|
|
|
|
|
- AddItemCommand = ReactiveCommand.Create(AddItem);
|
|
|
-
|
|
|
- RemoveItemCommand = ReactiveCommand.Create(Remove);
|
|
|
+ RemoveItemCommand = ReactiveCommand.Create(() => Remove());
|
|
|
|
|
|
SelectFirstCommand = ReactiveCommand.Create(() => SelectItem(0));
|
|
|
|
|
@@ -55,7 +54,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public AvaloniaList<ItemViewModel> SelectedItems { get; }
|
|
|
= new AvaloniaList<ItemViewModel>();
|
|
|
|
|
|
- public AvaloniaList<ItemViewModel> Items
|
|
|
+ public IReactiveList<ItemViewModel> Items
|
|
|
{
|
|
|
get { return _items; }
|
|
|
private set { this.RaiseAndSetIfChanged(ref _items, value); }
|
|
@@ -94,11 +93,11 @@ namespace VirtualizationDemo.ViewModels
|
|
|
public IEnumerable<ItemVirtualizationMode> VirtualizationModes =>
|
|
|
Enum.GetValues(typeof(ItemVirtualizationMode)).Cast<ItemVirtualizationMode>();
|
|
|
|
|
|
- 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 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 void RandomizeSize()
|
|
|
{
|
|
@@ -124,7 +123,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
{
|
|
|
var items = Enumerable.Range(0, count)
|
|
|
.Select(x => new ItemViewModel(x));
|
|
|
- Items = new AvaloniaList<ItemViewModel>(items);
|
|
|
+ Items = new ReactiveList<ItemViewModel>(items);
|
|
|
}
|
|
|
else if (count > Items.Count)
|
|
|
{
|
|
@@ -163,7 +162,7 @@ namespace VirtualizationDemo.ViewModels
|
|
|
_prefix = _prefix == "Item" ? "Recreated" : "Item";
|
|
|
var items = Enumerable.Range(0, _itemCount)
|
|
|
.Select(x => new ItemViewModel(x, _prefix));
|
|
|
- Items = new AvaloniaList<ItemViewModel>(items);
|
|
|
+ Items = new ReactiveList<ItemViewModel>(items);
|
|
|
}
|
|
|
|
|
|
private void SelectItem(int index)
|