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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem with DataBinding to Series

Thread ID:

Created:

Updated:

Platform:

Replies:

123468 Mar 20,2016 06:58 PM Mar 22,2016 06:33 AM WPF 3
loading
Tags: SfChart
Melvin Smith
Asked On March 20, 2016 06:58 PM

Hello,
I have a treeview and when I click on an item I want to refresh a WPF default grid and also a sfchart control. My XAML Looks like this:

    <Window.DataContext>
        <viewModel:VMmainWindow />
    </Window.DataContext>
    <Grid Margin="0,10,2,0">
        <DataGrid x:Name="dataGrid" Margin="0,10,218,329" ItemsSource="{Binding SelectedStock.StockData}" HorizontalAlignment="Right" Width="405" />
        <syncfusion:TreeViewAdv ItemsSource="{Binding Indices}" SelectedTreeItem="{Binding SelectedStock}" Margin="10,10,628,329">
            <syncfusion:TreeViewAdv.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Stocks}">
                    <TextBlock Text="{Binding Symbol}" />
                </HierarchicalDataTemplate>
            </syncfusion:TreeViewAdv.ItemTemplate>
        </syncfusion:TreeViewAdv>
        <DockPanel HorizontalAlignment="Left" Height="314" LastChildFill="False" Margin="10,235,0,0" VerticalAlignment="Top" Width="770">
            <syncfusion:SfChart x:Name="Chart"   Margin="5,0,10,0">
                <syncfusion:SfChart.DataContext>
                    <viewModel:VMmainWindow></viewModel:VMmainWindow>
                </syncfusion:SfChart.DataContext>
                <syncfusion:SfChart.PrimaryAxis>
                    <syncfusion:DateTimeAxis  Header="Date"/>
                </syncfusion:SfChart.PrimaryAxis>
                <syncfusion:SfChart.SecondaryAxis>
                    <syncfusion:NumericalAxis  Header="Value"/>
                </syncfusion:SfChart.SecondaryAxis>
                <syncfusion:LineSeries  x:Name="series1" XBindingPath="Date" YBindingPath="Close" ItemsSource="{Binding SelectedStock.StockData}"/>
            </syncfusion:SfChart>
        </DockPanel>
    </Grid>

My ViewModel:
    public class VMmainWindow
    {
        public List<Model.Index> Indices { get; set; }
        public Model.Stock SelectedStock { get; set; }
        public VMmainWindow()
        {
            this.Indices = new List<Model.Index>();
            this.Indices.Add(new Model.Index());
        }

For the moment I haven't implemented INotifyPropertyChanged in my model classes though the datagrid is already correctly updated when I Change the selection in the treeview, but the sfchart isn't (stays empty).
What can I do that this works?
Thanks in advance!

Melvin


Sumathi Jayaraj [Syncfusion]
Replied On March 21, 2016 12:33 PM

Hi Melvin,

Thanks for contacting Syncfusion Support.

We are unable to reproduce your reported problem. Please provide us more information probably a sample to reproduce the reported issue.

Regards,
Sumathi J

Melvin Smith
Replied On March 21, 2016 01:52 PM

Hi Sumathi,
I attached a zip Folder with my solution.
You will see that selecting an item in the treeview will refresh the grid, but not the Chart. Could you tell me why this isn't the case ?
Best regards
Melvin

Attachment: HistoricalStockDataGetter_b54ee62d.zip

Sumathi Jayaraj [Syncfusion]
Replied On March 22, 2016 06:33 AM

Hi Melvin,
 
Thanks for the update.
 
The problem occurs because the Window and SfChart are having their own DataContext. We have resolved the problem in the sample by removing DataContext from SfChart. Please find the modified sample from the below location.
 
Sample: HistoricalStockDataGetter
 
Regards,
Sumathi J

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.

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

;