Chart presentation in XAML with ContentPresenter
Chart presentation in XAML with ContentPresenter
I need to add a collection of charts to a userinterface in wpf or silverlight
my code is like the following example:
C#:
ObservableCollection<TChart> ChartsCollection = new ObservableCollection<TChart>();
XAML:
<ListBox ItemsSource="{Binding ChartsCollection}">
</ListBox>
As the TChart object is derived from Control, why is the ListBox control not showing the chart objects?
When i change the heigt of the TChart object to 100 or 200, this change is visible in the ListBoxItems,
Which means the ItemsSource binding can find the TChart object, but cannot "render" the charts.
Am I missing something, or is this not possible in WPF?
my code is like the following example:
C#:
ObservableCollection<TChart> ChartsCollection = new ObservableCollection<TChart>();
XAML:
<ListBox ItemsSource="{Binding ChartsCollection}">
</ListBox>
As the TChart object is derived from Control, why is the ListBox control not showing the chart objects?
When i change the heigt of the TChart object to 100 or 200, this change is visible in the ListBoxItems,
Which means the ItemsSource binding can find the TChart object, but cannot "render" the charts.
Am I missing something, or is this not possible in WPF?
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
Can you try to send us a simple project, so we can reproduce exactly your problem here and can try to help you to find a good solution?
Thanks,
Can you try to send us a simple project, so we can reproduce exactly your problem here and can try to help you to find a good solution?
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Chart presentation in XAML with ContentPresenter
Yes, i will create a sample project this week, just returned from holiday.
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
Thank you,we will wait your project .
Thanks,
Thank you,we will wait your project .
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Chart presentation in XAML with ContentPresenter
Here is a sample project for what I want to achieve, using the MVVM pattern
MainView.xaml contains a listbox.
the datacontext of the MainView is set to the MainVM class.
the itemssource of the listbox is bound to the ChartsCollection property of MainVM.
I expected the lisbox to show the chartobjects from the Chartscollection.
The behaviour in this sample project is not what I expected, but this sample project should give an
idea of my goal.
Hope you can help me,
best regards
MainView.xaml contains a listbox.
the datacontext of the MainView is set to the MainVM class.
the itemssource of the listbox is bound to the ChartsCollection property of MainVM.
I expected the lisbox to show the chartobjects from the Chartscollection.
The behaviour in this sample project is not what I expected, but this sample project should give an
idea of my goal.
Hope you can help me,
best regards
- Attachments
-
- testApplication.rar
- sample project
- (43.42 KiB) Downloaded 443 times
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
We are doing test with your project and we try to give you an answer asap with it.
Thanks,
We are doing test with your project and we try to give you an answer asap with it.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Chart presentation in XAML with ContentPresenter
Hello Sandra,
Can you give me an update about the status of this topic?
Can you give me an update about the status of this topic?
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
We are working in it, we try to provide you and answer asap.
Thanks,
We are working in it, we try to provide you and answer asap.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
Sorry, for the delay. We have been investigating, and we inform you that there are controls as example, list box that doesn't have Height and Width until you doesn’t add any elements with determinate Height and Width. And also, we add a simple code where you can check it and at the same time, I think you can use it to achieve as you want.
Thank you,
Sorry, for the delay. We have been investigating, and we inform you that there are controls as example, list box that doesn't have Height and Width until you doesn’t add any elements with determinate Height and Width. And also, we add a simple code where you can check it and at the same time, I think you can use it to achieve as you want.
Code: Select all
MainVM _vm = new MainVM();
public MainView()
{
InitializeComponent();
this.DataContext = _vm;
this.Loaded += new RoutedEventHandler(MainView_Loaded)
}
void MainView_Loaded(object sender, RoutedEventArgs e)
{
foreach (object logicalChild in LogicalTreeHelper.GetChildren(this))
if (logicalChild is System.Windows.Controls.DockPanel)
{
System.Windows.Controls.DockPanel dockPanel = ((System.Windows.Controls.DockPanel)(logicalChild));
foreach (object dockChild in LogicalTreeHelper.GetChildren(dockPanel))
{
if (dockChild is System.Windows.Controls.ListBox)
{
System.Windows.Controls.ListBox listBox1 = (System.Windows.Controls.ListBox)dockChild;
foreach (Steema.TeeChart.WPF.TChart chart in listBox1.Items)
{
chart.Height = this.Height;
chart.Width = this.Width;
}
}
}
}
}
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Chart presentation in XAML with ContentPresenter
Hi Sandra,
Thanks for the suggestion, but this is not exactly what i was looking for.
I tested you solution and the charts were presented correctly instead of chart.width, but that can be another xaml setting.
The chart width and heigt are still static.
This solution will not work in Silverlight, because Silverlight has no LogicalTreeHelper.
Last week I created another workaround which works better for me.
see http://www.teechart.net/support/viewtop ... 47&start=0 were i reported the bug in the silverlight dll.
in this solution I add datagrid rows dynamicly to a named Grid element. this solution works better for me and the charts are resized automatically to the row's width and heigt.
I still haven't figured out a way to add charts by using the MVVM pattern, but the workaround I use now works for me.
best regards
Thanks for the suggestion, but this is not exactly what i was looking for.
I tested you solution and the charts were presented correctly instead of chart.width, but that can be another xaml setting.
The chart width and heigt are still static.
This solution will not work in Silverlight, because Silverlight has no LogicalTreeHelper.
Last week I created another workaround which works better for me.
see http://www.teechart.net/support/viewtop ... 47&start=0 were i reported the bug in the silverlight dll.
in this solution I add datagrid rows dynamicly to a named Grid element. this solution works better for me and the charts are resized automatically to the row's width and heigt.
I still haven't figured out a way to add charts by using the MVVM pattern, but the workaround I use now works for me.
best regards
Re: Chart presentation in XAML with ContentPresenter
Hello wdl,
Thanks for your information. I am glad that you can find a solution for your problem.
Thanks,
Thanks for your information. I am glad that you can find a solution for your problem.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |