Radical Documentation
View on GitHub
release-2
release-2
  • Home
  • Presentation
    • AbstractViewModel
    • Conventions
      • Bootstrap Conventions
      • Runtime Conventions
      • Conventions override
    • Commands and DelegateCommand
    • IViewResolver
      • Default view behaviors
      • view life cycle events
        • Callback expectations
        • notify messages
    • Message broker MVVM built-in messages
    • Application boot process
      • Application configuration
      • Application shutdown
      • Singleton applications
    • AbstractMementoViewModel
      • Simple ViewModel graphs
      • Collections and complex ViewModel graphs
    • Validation and Validation Services
    • Resources
      • Services as resources
      • ViewModels as resources
    • UI Composition
      • Region content lifecycle
      • TabControl region
      • Create a custom region
  • Concepts
    • Inversion of Control
      • Third party DI containers
    • Entities
      • Property System
    • Messaging and Message Broker
      • POCO messages
      • Standalone message handlers
    • Observers
      • PropertyObserver
      • MementoObserver
      • BrokerObserver
  • Memento
    • Change Tracking Service
      • MementoEntity and MementoEntityCollection
      • Handling change tracking:
        • Simple model
        • Collections
        • Complex objects graph
      • Atomic operations
      • Change Tracking Service API
      • Property Metadata for the ChangeTrackingService
      • Handling collection sync
      • Property State
  • Behaviors
    • DataGrid Behaviors
    • Password
    • Generic routed event handler to command behavior
    • Overlay adorner
      • Busy status manager
    • TextBox behaviors:
      • Command
      • Auto select
      • DisableUndoManager (.Net 3.5 only)
  • Markup Extensions
    • Editor binding
    • Auto Command binding
  • How to
    • Get the view of a given view model
    • Bi-directional communication between different windows/views
    • Handle the busy status during async/long running operations
    • Implement a customer improvement program
    • Manage focus
    • Create a splash screen
    • Access view model after view is closed
    • Intercept ViewModels before they are used
  • Upgrade guides
    • Radical Presentation 1.x to Radical 2.x for .NET Core
Powered by GitBook
On this page
  1. Memento
  2. Change Tracking Service
  3. Handling change tracking:

Collections

PreviousSimple modelNextComplex objects graph

Last updated 4 years ago

We briefly introduced and seen how to .

We can go further and introduce collection change tracking:

var list = new MementoEntityCollection<String>();
memento.Attach(list);

list.Add("a");
list.Add("b");
list.Add("c");

var count = list.Count; //3

memento.Undo();
//list.Count 2

memento.Redo();
//list.Count 3

The MementoEntityCollection<T> being a memento entity will keep track of changes applied to collection structure. Each change will be tracked: Add, Remove, Clear, Insert, InsertAt, etc...

var list = new MementoEntityCollection<Person>();
memento.Attach(list);

list.Add(new Person());

Adding a MementoEntity, such as Person, will automatically trigger the memento that will start tracking the Person instance:

var list = new MementoEntityCollection<Person>();
memento.Attach( list );

var person = new Person();
list.Add( person );

person.FirstName = "name";

memento.Undo(); //the person first name is reverted
memento.Undo(); //the person instance is removed from the collection
memento.Redo(); //the person instance is added once again to the collection

As expected the changes stack is handled in the correct order. The next step is to understand how to .

MementoEntity and MementoEntityCollection
track changes in a simple graph
handle change tracking in complex objects graph