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" <TextBox Watermark="Item to Create"
UseFloatingWatermark="True" UseFloatingWatermark="True"
Text="{Binding NewItemString}"/> 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 RemoveItemCommand}">Remove Item</Button>
<Button Command="{Binding RecreateCommand}">Recreate</Button> <Button Command="{Binding RecreateCommand}">Recreate</Button>
</StackPanel> </StackPanel>

18
samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs

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

Loading…
Cancel
Save