NorthwoodsSoftware / GoDiagram

.NET diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
Other
75 stars 11 forks source link

Bind Diagram to ViewModel #6

Closed rasta-mouse closed 3 months ago

rasta-mouse commented 3 months ago

I feel dumb asking this but is it possible to bind a Diagram to a view model property, rather than using the code-behind?

I have the control:

<go:DiagramControl
        Diagram="{Binding MyGraph}"
        Width="1920" Height="1080"
        Background="#202020" />

and my view model:

public sealed class DiagramViewModel : ViewModelBase
{
    public Diagram MyGraph { get; set; }  = new();
}

But I get the following error when I try to build:

Error AVLN:0004 Avalonia: Unable to find suitable setter or adder for property Diagram of type Northwoods.GoDiagram.Avalonia:Northwoods.Go.Avalonia.DiagramControl for argument Avalonia.Markup.Xaml:Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindingExtension, available setter parameter lists are:
Northwoods.Go.Diagram
Northwoods.Go.Part
Northwoods.Go.Part Line 12, position 9.
jonchardy commented 3 months ago

Not at this time. GoDiagram was designed to support multiple .NET platforms, so for compatibility between them, we manage the instantiation of the Diagram class internally.