WPF MVVM Chart change axes

Posted by c0uchm0nster on Stack Overflow See other posts from Stack Overflow or by c0uchm0nster
Published on 2010-06-11T17:07:16Z Indexed on 2010/06/11 17:12 UTC
Read the original article Hit count: 484

Filed under:
|
|

I'm new to WPF and MVVM. I'm struggling to determine the best way to change the view of a chart. That is, initially a chart might have the axes: X - ID, Y - Length, and then after the user changes the view (either via lisbox, radiobutton, etc) the chart would display the information: X - Length, Y - ID, and after a third change by the user it might display new content: X - ID, Y - Quality.

My initial thought was that the best way to do this would be to change the bindings themselves. But I don't know how tell a control in XAML to bind using a Binding object in the ViewModel, or whether it's safe to change that binding in runtime?

Then I thought maybe I could just have a generic Model that has members X and Y and populate them as needed in the viewmodel?

My last thought was that I could have 3 different chart controls and just hide and show them as appropriate.

What is the CORRECT/SUGGESTED way to do this in the MVVM pattern? Any code examples would be greatly appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mvvm