I have a MVVM trading application.
MainView
has two tab controls - left one displays a collection of "workspaces"
and the right one displays dynamic data display charts.
When I create the first "chartviewmodel"
the correct chart appears in the right tab control as expected.
When I then create another "chartviewmodel"
with different data that should result in a different chart, that's not what happens. The second tab item is a duplicate of the first from a visual standpoint. The tab items are contained in a collection of items called: "chartspaces"
and in debug mode I can see each viewmodel and indeed each has different values.
Also, in debug mode I put a breakpoint on the "Initialize()"
method of the view and when the first chartviewmodel
is created, that method indeed gets called. When I then create the second chartviewmodel
, the "Initialize()"
method is not called, so in fact another view is not getting created...but I can't figure out why.
My view/viewmodel's are tied together via DataTemplate
with x:Shared="False"
(tried it with and without this parameter). I've traced through the constructor of the chartviewmodel
to ensure it was not getting any errors and it is not.
On the left-most tab control, I can create multiple tradeviewmodel
and each results in a different view... in other words it is behaving as expected.
My XAML for the right tab control is essentially the same as for the left one with the exception of the "workspace"
collection (left uses "workspaces"
right uses "chartspaces"
so I'm at a loss as to what might be wrong or how to diagnose this problem further.
The datatemplate looks like:
<DataTemplate x:Shared="False" DataType="{x:Type vm:ModelOptionChainViewModel}">
<vw:DDDRiskChart />
</DataTemplate>
In further experimenting, I put the tab items on the left side instead and found the same problem, but if I selected a non-Dynamic Data Display tab item, then one of the DDD charts, they display correctly. So, before I selected a DDD chart I had to display a non-DDD chart, then the DDD chart for it to display.
So, moving the tab items back to the right tab control, I put the two DDD charts in, then put in a non-DDD chart (a DataVisualization chart). I found the same behavior...if I selected the non-DDD chart and then the DDD chart, it displays correctly. If I just alternate between the two DDD charts, they will both display the same graph! Is that not weird?