RotationAngle oldValue and newValue is null in ModelChangedEventArgs

Hi Walter,

Basically I want to get the RotationAngle property changed in GoXamModel.Changed event. I have a custom event attached to it but to this event I have put a filter something like this

    private void OnDiagramModified(object sender, GoXam.ModelChangedEventArgs e)
    {            
        try
        {
            if (e.Change.Equals(ModelChange.CommittedTransaction) && e.OldValue != null)
            {
               //Custom Code
            }
         }
      }

When I rotate the node this event is called but I see that the filter is making is bypass as e.OldValue is null as well as e.NewValue.

I also have a property in my NodeData for RotationAngle for serialization

Am I missing some initialization ? What is the reason for the data being null ?

Can’t you just use a TwoWay Binding on the Node.RotationAngle attached property?

Not actually as the architecture implementation doesn’t allow us to do that. I have to get every changes done via GoXam.Model changed event alone.

Rotate function is like this

    public void RotateAggregate(bool isClockwiseRotation)
    {
        GoXamModel.StartTransaction("RotateAggregates");
        GetSelectedNodes()?.ToList().ForEach(node =>
        {
            if (isClockwiseRotation)
            {
                node.RotationAngle += 90;
            }
            else
            {
                node.RotationAngle -= 90;
            }
            node.LinksConnected.ToList().ForEach(link => { link.Route.UpdateLayout(); link.Route.RecomputePoints(); });
            node.UpdateLayout();
            node.UpdateAdornments();
        });
        GoXamModel.CommitTransaction("RotateAggregates");
    }

This works perfectly. But for rotate I have to bind undo-redo and also for serialization I have to notify the next layer in my architecture via ModelChanged event alone.

Everything seems to work OK when I try a Model Changed event handler:

    private void Model_Changed(object sender, ModelChangedEventArgs e) {
      if (e.Change == ModelChange.Property && e.PropertyName == "Angle") {
        System.Diagnostics.Debug.WriteLine(e.ToString());
      }
    }

During a rotation the output window has messages like:

!  Property Angle: E old: 0 new: 375
!  Property Angle: E old: 375 new: 15

Where “E” is the key of the node that I am rotating.

That is right but as I mentioned initially we have the filter that blocks if the e.OldValue is null and For RotationAngle property changed the OldValue was coming as null and I wanted to know the reason for it.

Actually I found the reason and its because in the Node shape template the Data.RotationAngle property was not binded in the xaml. After binding I started getting the values in the oldValue