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