Saturday, March 21, 2009

Using the Silverlight Charting control with WPF

You have probably already seen the great charting control that is part of the Silverlight Toolkit. I don’t know for you, but I have on many occasions looked at these beautiful charts with envy. And really, who doesn’t want to have impressive charts in his application these days. And I wondered if I could use these nice charts in my WPF applications. The first idea that occurred to me was that I could host a Silverlight application in my WPF application using the WebBrowser control. However, this approach seemed somewhat hacky to me so I started looking if I could build the Silverlight charting control against WPF. It seems, however that the guys from the Silverlight team had also thought of that and they even have their daily builds setup to build the Silverlight charting against WPF.

So here is Delay’s chart builder sample that you have already probably seen running on Silverlight, but this time running on my desktop with WPF:

ChartBuilder

The sample includes all assemblies necessary.

You should note that to use the Silverlight charting control with WPF you must have a reference not only to the DataVisualization assembly, but to the WPFToolkit assembly or you will get some strange errors. This is because the control uses the the Visual State Manager that is being ported to WPF.

Happy charting.

No comments: