GoWPF 3.0.3 - Stacked items in palette?

Hello,

in my sample app, i have a grid with 3 columns.
Left column => Nodes palette
Center column => Graph links diagram
Right column => Links palette.

Problem i have is, that when i fill the links palette (LinksSource), they are all stacked over each other.

When i resize the column, then it seems to get recalculated and everything is shown as expected.
image

Question, what to i need to do, in order to get it shown correctly without manual resize intervention from the operator? - What i tested is, i added a NodeSource with one node, and removed it, then it is shown correctly or least forced to do so. - But this is currently just a workarround which i want to remove.

Maybe force another layout (Diagram.LayoutDiagram()) after a short while?

Ok, this might work then. - I would need to implement a method in my viewmodel, which triggers this on the diagram. - Usually a relation i try to avoid in MVVM.

Funny thing is, when i set a NodeSource and at one Node, then immediately remove it again, all gets arranged correctly.

Question is, why is’nt this the case for palettes, who only have a LinksSource set also?

In a Diagram.InitialLayoutCompleted listener of the Palette you could try a Dispatcher.BeginInvoke to call the LayoutDiagram call later.

Thank you walter, i call now LayoutDiagram() within InitialLayoutCompleted, which totally does the job.

Additionally, i made a custom palette, and added a new dependency property:

    #region Dependency properties

    public bool TriggerLayoutDiagram
    {
        get { return (bool)GetValue(TriggerLayoutDiagramProperty); }
        set { SetValue(TriggerLayoutDiagramProperty, value); }
    }

    public static readonly DependencyProperty TriggerLayoutDiagramProperty =
        DependencyProperty.Register("TriggerLayoutDiagramProperty",
        typeof(bool),
        typeof(CustomPalette),
        new FrameworkPropertyMetadata(false,
                                      FrameworkPropertyMetadataOptions.AffectsRender,
                                      new PropertyChangedCallback(OnTriggerLayoutDiagramChanged)));

    private static void OnTriggerLayoutDiagramChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var palette = d as CustomPalette;

        if (palette is not null)
        {
            if (e.NewValue is bool newValue)
            {
                if (newValue)
                {
                    palette.LayoutDiagram();
                }
            }
        }
    }

    #endregion

Then i bind this to my viewmodel property, and am able to trigger a “re-layouting” of the diagram, whenever i have the urge to do so.

Solved for me.