Browse Source

added button to prepend and append items to list.

pull/554/head
danwalmsley 10 years ago
parent
commit
defae349a7
  1. 3
      samples/VirtualizationTest/MainWindow.xaml
  2. 18
      samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs

3
samples/VirtualizationTest/MainWindow.xaml

@ -20,7 +20,8 @@
<TextBox Watermark="Item to Create"
UseFloatingWatermark="True"
Text="{Binding NewItemString}"/>
<Button Command="{Binding NewItemCommand}">Insert Item</Button>
<Button Command="{Binding PrePendItemCommand}">Pre-Pend Item</Button>
<Button Command="{Binding AppendItemCommand}">Append Item</Button>
<Button Command="{Binding RemoveItemCommand}">Remove Item</Button>
<Button Command="{Binding RecreateCommand}">Recreate</Button>
</StackPanel>

18
samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs

@ -21,8 +21,11 @@ namespace VirtualizationTest.ViewModels
RecreateCommand = ReactiveCommand.Create();
RecreateCommand.Subscribe(_ => Recreate());
NewItemCommand = ReactiveCommand.Create();
NewItemCommand.Subscribe(_ => Create());
AppendItemCommand = ReactiveCommand.Create();
AppendItemCommand.Subscribe(_ => Append());
PrePendItemCommand = ReactiveCommand.Create();
PrePendItemCommand.Subscribe(_ => PrePend());
RemoveItemCommand = ReactiveCommand.Create();
RemoveItemCommand.Subscribe(_ => Remove());
@ -52,7 +55,9 @@ namespace VirtualizationTest.ViewModels
private set { this.RaiseAndSetIfChanged(ref _items, value); }
}
public ReactiveCommand<object> NewItemCommand { get; private set; }
public ReactiveCommand<object> AppendItemCommand { get; private set; }
public ReactiveCommand<object> PrePendItemCommand { get; private set; }
public ReactiveCommand<object> RecreateCommand { get; private set; }
@ -78,11 +83,16 @@ namespace VirtualizationTest.ViewModels
}
}
private void Create()
private void Append()
{
Items.Add(new ItemViewModel(Items.Count, NewItemString));
}
private void PrePend ()
{
Items.Insert(0, new ItemViewModel(0, NewItemString));
}
private void Remove()
{
if (SelectedItem != null)

Loading…
Cancel
Save