Ghost1372

everything can be handy

UndoRedoObservableCollection

List and ObservableCollection which support undo/redo.

You can use both in the List and ObservableCollection.

UndoRedoList and UndoRedoObservableCollection is not Available in .Net 4.0, .Net 4.5, .Net 4.5.1, .Net 4.5.2, .Net 4.6, .Net 4.6.1 and .Net 4.6.2

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
UndoRedoObservableCollection<string> list = new UndoRedoObservableCollection<string>();
// OR
// UndoRedoList<string> list = new UndoRedoList<string>();
public MainWindow()
{
InitializeComponent();
list.Add("Hello");
list.Add("Bye");

// Result: Hello, Bye
}
private void AddToList_Click(object sender, RoutedEventArgs e)
{
list.Add("Welcome");
// Result: Hello, Bye, Welcome
}

private void Undo_Click(object sender, RoutedEventArgs e)
{
list.Undo();
// Result: Hello, Bye
}
private void Redo_Click(object sender, RoutedEventArgs e)
{
list.Redo();
// Result: Hello, Bye, Welcome
}

0%