OK this is probably simple, but I can't seem to wrap my mind around it. I'm using PRISM with a WINRT application that uses SFChart. The chart is created in XAML, it's data is all set via data binding to an observablecollection. Now I see there is a function on the chart that lets me save it using something like chart.save(). I get to thinking that is awesome! I could add a feature to my app that would let me have a user click a button where it saves the chart out, attaches it to an email object and then calls the OS's send email function. Instant ability to send charts to anyone! However, the chart on it's own though isn't very helpful without something that explains it. Luckily I've already got data on the page (also bound from the viewmodel) that I can add to the email to make the chart make sense. So simple steps, call save function, attach to email object, add text to the email from strings that exists in the viewmodel, and send it.
The problem: with MVVM I need to have that button fire off a delegate command which resides in the ViewModel, which knows nothing about the chart...which means I can't call the save function. Now I suppose I could walk the visual tree somehow (which I don't know how to do yet either) and find the chart object so I can call its save function, but now I'm making my viewmodel depend on the view which is not great design. I could could call the save function directly from the code behind, which would be fine except (since I'm not manipulating data for view) but then I have the problem of the fact that I also need to add strings to the email and those strings exist in the ViewModel. Also I don't understand if I do it that way if I have to create the chart in codebehind vs in XAML, or if there is a way to link some sort of chart object to the existing object created in XAML just to use the print function.
What is the "proper" way to accomplish this scenario using MVVM design principles?
Thanks!