2using System.Threading.Tasks;
3using System.Windows.Input;
14 private readonly
Command moveUp;
15 private readonly
Command moveDown;
29 public ICommand
MoveUp => this.moveUp;
42 if (this.items.UntypedValue is Array A)
43 return Array.IndexOf(A,
this) > 0;
53 if (this.items.UntypedValue is not Array Items)
54 return Task.CompletedTask;
56 Items = (Array)Items.Clone();
58 int i = Array.IndexOf(Items,
this);
60 return Task.CompletedTask;
62 object Item1 = Items.GetValue(i - 1);
63 object Item2 = Items.GetValue(i);
65 Items.SetValue(Item2, i - 1);
66 Items.SetValue(Item1, i);
68 this.items.UntypedValue = Items;
70 return Task.CompletedTask;
79 if (this.items.UntypedValue is Array A)
80 return Array.IndexOf(A,
this) < A.Length - 1;
90 if (this.items.UntypedValue is not Array Items)
91 return Task.CompletedTask;
93 Items = (Array)Items.Clone();
95 int i = Array.IndexOf(Items,
this);
96 if (i < 0 || i >= Items.Length - 1)
97 return Task.CompletedTask;
99 object Item1 = Items.GetValue(i + 1);
100 object Item2 = Items.GetValue(i);
102 Items.SetValue(Item2, i + 1);
103 Items.SetValue(Item1, i);
105 this.items.UntypedValue = Items;
107 return Task.CompletedTask;
Defines a custom command.
Abstract base class for ordered items
bool CanExecuteMoveUp()
If the item can be moved up.
ICommand MoveUp
Moves the item up in the ordered list
bool CanExecuteMoveDown()
If the item can be moved up.
ICommand MoveDown
Moves the item down in the ordered list
Task ExecuteMoveDown()
Moves the item up.
Task ExecuteMoveUp()
Moves the item up.
Abstract base class for view models
Interface for properties.