<syncfusion:SfDiagram x:Name="diagram"
Nodes="{Binding Nodes}"
Connectors="{Binding Connectors}"
SelectedItems="{Binding SelectedNode}"
LayoutManager="{Binding Layout}"
Constraints="Default,Virtualize,Outline"/>
<!--<syncfusion:SfDiagram x:Name="diagram" />--> |
S.No |
Query |
Response | |
1 |
Thanks for your answer! You are right! This works, but I did comment it out on purpose: You first wrote, that I should change to DataSource and therefore I added this in the Class pagVariantCustomization.xaml.cs: |
The error occurs due to the Connectors and Nodes collection not initialized in the diagram(view). If you don’t want to bind the viewmodel with view, then you need to initialize the connectors and nodes collection in the view class.
Code Example:
| |
2 |
I did it in the class, because I don't know how to use the ObservableCollection Nodes defined in the ViewModel as a StaticResource like this e.g.:
<="" div="" style="box-sizing: border-box;">
DataSource="{Binding Nodes}" />
This is not working :-(
What do I have to do?
|
If you want to define the datasource in xaml as a static resource, you can define it as like in the below page.
And in your sample, we could find that “Allgemein._viewModel_VariantCustomization.Nodes” collection is empty. So, it returns empty datasource.
If you want to create a Layout using DataSource, you must define Id and ParentId values for each and every data in the datasource. Based on the information, Diagram can be populated with the nodes and connectors. |
<syncfusion:SfDiagram x:Name="diagram"
DataSourceSettings="{Binding DataSourceForDiagram}"
LayoutManager="{Binding LayoutManagerForDiagram}">
<syncfusion:SfDiagram.Nodes>
<syncfusion:NodeCollection></syncfusion:NodeCollection>
</syncfusion:SfDiagram.Nodes>
<syncfusion:SfDiagram.Connectors>
<syncfusion:ConnectorCollection></syncfusion:ConnectorCollection>
</syncfusion:SfDiagram.Connectors>
</syncfusion:SfDiagram> |