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. Image for the cookie policy date
close icon

Issue with Data Binding business objects to the diagram model.

I am evaluating the data binding feature with directed-tree layout and am unable to make it work. I would really appreciate if you can provide me a working sample of the data binding or let me know what am I doing wrong.

Here is what I have so far

XAML -


















Orientation="TopBottom"
x:Name="diagramModel"
SpaceBetweenSubTrees="100"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource dataTemplate}">









C# -

public MainWindow()
{
InitializeComponent();

List CountrySalesList = new List();

CountrySalesList.Add(new CountrySale() { Name = "US" });

CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "New York", Revenue = 2353 });

CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "Texas", Revenue = 3453 });

CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "California", Revenue = 8456 });

this.DataContext = CountrySalesList;
}


Thanks
KK



1 Reply

JR Jegan R Syncfusion Team October 21, 2010 04:57 AM UTC

Hi Kiran,

Thanks for evaluating Syncfusion products.

Currently, ItemSource for DiagramModel can be specified in two ways, either by binding it to a StaticResource or by directly assigning an object to ItemSource in the CodeBehind as shown in the following code snippet.

Code Snippet:

public MainWindow()
{
InitializeComponent();
List CountrySalesList = new List();
CountrySalesList.Add(new CountrySale() { Name = "US" });
CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "New York", Revenue = 2353 });
CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "Texas", Revenue = 3453 });
CountrySalesList[0].RegionalSales.Add(new RegionSale() { Name = "California", Revenue = 8456 });
this.diagramModel.ItemsSource = CountrySalesList;
}

Please refer the sample form the following link.

Sample Link: http://files.syncfusion.com/Support/Diagram.WPF/Samples/72991/DataBindingSample.zip

This is because DiagramModel class just extends DependencyObject, so ItemsSource cannot be binded to any property. However, we have fixed this issue and this fix will be available in our Volume 4 2010 release, which is tentatively scheduled to be held on the last week of October 2010.

Also this forum is a duplicate of incident #72991, please follow up with this incident.

Please let us know if there are any concerns.

Regards,
Jegan


Loader.
Live Chat Icon For mobile
Up arrow icon