We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dificulties on Binding Data From DataSource to Nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

150300 Dec 31,2019 02:03 PM UTC Jan 2,2020 07:15 AM UTC Xamarin.Forms 1
loading
Tags: SfDiagram
Apdata
Asked On December 31, 2019 02:03 PM UTC

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
            };

Devaraj Sekar [Syncfusion]
Replied On January 2, 2020 07:15 AM UTC

Hi customer, 
 
Thank you for contacting Syncfusion support. 
 
The data template binding for node while implementing “Layout” in SfDiagram should be carried out in code level. The data binding from xaml level for layout will not reflect in node since, it is the behavior of SfDiagram. We have prepared a sample based on the provided details, which can be downloaded from the below link. 
 
 
Kindly let us know if you require any further assistance. 
 
Regards, 
Devaraj S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon