Guest User

Untitled

a guest
Oct 15th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public ObservableCollection<NumberViewModel> Nummer { get; private set; } = new ObservableCollection<NumberViewModel>();
  2. private int _currentNumber;
  3. public int current
  4. {
  5. get
  6. {
  7. return _currentNumber;
  8. }
  9. set
  10. {
  11. _currentNumber = value;
  12. OnPropertyChanged();
  13. }
  14. }
  15.  
  16. public ICommand CountUpCommand { get; private set; }
  17. public ICommand DelCommand { get; private set; }
  18.  
  19. Number Zahl = new Number();
  20.  
  21. public CounterViewModel()
  22. {
  23. CountUpCommand = new Command(CountUp);
  24. DelCommand = new Command(SetZero);
  25. }
  26.  
  27. public void SetZero()
  28. {
  29. current = 0;
  30. Nummer.Add(new NumberViewModel { Num = current});
  31. }
  32.  
  33. public void CountUp()
  34. {
  35.  
  36. current = current + 1;
  37. Nummer.Add(new NumberViewModel { Num = current });
  38.  
  39. }
  40.  
  41. <StackLayout>
  42. <Button Text="+1" Command="{Binding CountUpCommand}" x:Name="plusOne" />
  43. <Button Text="DEL" Command="{Binding DelCommand}" />
  44. </StackLayout>
  45. <Label Text="--------------" />
  46. <StackLayout>
  47. <ListView ItemsSource="{Binding Nummer}">
  48. <ListView.ItemTemplate>
  49. <DataTemplate>
  50. <TextCell
  51. Text="{Binding Num}"
  52. x:Name="ElNr"
  53. />
  54. </DataTemplate>
  55. </ListView.ItemTemplate>
  56. </ListView>
  57. </StackLayout>
Add Comment
Please, Sign In to add comment