NullReferenceException while updating a layout RRS feed

  • Question

  • Is anybody here? I'm trying to update layout after some changes with Edge (I'm binding some data to edge's label).

    private void Simulation()
                //TODO: start simulation
                foreach (var item in gViewer.Entities)
                    if (item.DrawingObject.UserData is ISimulation<ProductBase> obj)
                    if (item.DrawingObject is Edge edge)
                        edge.LabelText = this.toolPanelTime.Text = (edge?.SourceNode?.UserData as ISimulation<ProductBase>)?.Count.ToString() ?? "0";

    But I always get NullReferenceException when NeedToCalculate is set to 'false':

    internal virtual void RedoLayout()
                gViewer.NeedToCalculateLayout = false;
                gViewer.Graph = gViewer.Graph;
                gViewer.NeedToCalculateLayout = true;
                //gViewer.Graph = gViewer.Graph;

    If it's set to 'true' or this code is unrolled, everything work great.

    Exception occurs in Microsoft.Msagl.Drawing.Label when trying to obtain value from the Center property. How is that possible to fix it without calculation the layout?

    Source Code :

    Thanks in advance!

    Saturday, May 19, 2018 10:27 PM