Select to view content in your preferred language

How to update a viewmodel on undo

392
1
Jump to solution
08-31-2023 06:35 AM
MBambino_ATS
New Contributor III

I have a dockpane viewmodel with some controls in it that gets its data populated by selecting an element on the map. inside of the dockpane are some controls with operations that affect data. These operations are added to the undo stack and function properly, however, the viewmodel is not updated with undo/redo until the element is reselected from the map.
Is there an event to subscribe to or some sort of callback to set?

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Try to catch EditCompletedEvent event in your viewmodel. EditCompletedEventArgs has property CompletedType.

It describes the type of an EditCompletedEvent and could be one enum EditCompletedType values.

private Task OnEditCompleted(EditCompletedEventArgs args)
        {
            switch (args.CompletedType)
            {
            case EditCompletedType.Save:
                break;

            case EditCompletedType.Discard:
                break;

            case EditCompletedType.Operation:
                break;

            case EditCompletedType.Undo:
            case EditCompletedType.Redo:
                    // do your stuf
                break;

            case EditCompletedType.Reconcile:
                break;

            case EditCompletedType.Post:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }

View solution in original post

1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

Try to catch EditCompletedEvent event in your viewmodel. EditCompletedEventArgs has property CompletedType.

It describes the type of an EditCompletedEvent and could be one enum EditCompletedType values.

private Task OnEditCompleted(EditCompletedEventArgs args)
        {
            switch (args.CompletedType)
            {
            case EditCompletedType.Save:
                break;

            case EditCompletedType.Discard:
                break;

            case EditCompletedType.Operation:
                break;

            case EditCompletedType.Undo:
            case EditCompletedType.Redo:
                    // do your stuf
                break;

            case EditCompletedType.Reconcile:
                break;

            case EditCompletedType.Post:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }