Hello,
I'm trying to bind the information from datasource to diagram at XAML, but I wasn't able to accomplish it. I put below the XAML used as the code used.
I really would appreciate it if someone could point out what I'm doing wrong.
XAML:
<syncfusion:SfDiagram x:Name="diagram">
<syncfusion:SfDiagram.NodeTemplate>
<DataTemplate>
<Grid WidthRequest="80" HeightRequest="80" BindingContext="this">
<Label Text="{Binding name}" BackgroundColor="Red" TextColor="Green"/>
</Grid>
</DataTemplate>
</syncfusion:SfDiagram.NodeTemplate>
</syncfusion:SfDiagram>
Code:
employees = new ObservableCollection<Employee>();
employees.Add(new Employee() { name = "Elizabeth", id = 1, parentId = 0, designation = "CEO" });
employees.Add(new Employee() { name = "Christina", id = 2, parentId = 1, designation = "Manager" });
employees.Add(new Employee() { name = "Yang", id = 3, parentId = 1, designation = "Manager" });
diagram.DataSourceSettings = new DataSourceSettings()
{
DataSource = employees,
Id = "id",
ParentId = "parentId"
};
DirectedTreeLayout treeLayout = new DirectedTreeLayout()
{
HorizontalSpacing = 80,
VerticalSpacing = 80,
TreeOrientation = TreeOrientation.TopToBottom
};
diagram.LayoutManager = new LayoutManager()
{
Layout = treeLayout
};