Windows Phone 7 Chart Control Data-binding with xml (MVVM)

Sunday, December 18, 2011




Windows Phone 7 Provide you great Support of Data Visualization with Charts and Vector graphic. You can also bind chart with xml data by using mvvm pattern.

To Create Chart Control with XML.

1
Open Visual Studio 2010 then create new Silverlight windows Phone Project

2
Add XML file and define some schema



3
Add three Folders in Solution "Model", "View" , "ViewModel"

4
Add Class in Model name ResultView.cs and map your xml scheme with properties.


5
Add Class in ViewModel and Named ResultViewModel.cs in this class you load data from xml

6
Open App.xaml and define or copy from sample code in you Template for PhoneChart Portrait and Landscape orientation in ResourceDictionary.


7
Add one UserControl in your View Folder and named ResultView.xaml.

8
Open MainPage.xaml add View in it :)


9
Open MainPage.xaml and Override the OnOrientationChanged event handler and change template on On Orientation.

10
F5 and Enjoy :)

Download Source Code Here

By Usama Wahab Khan
for More Question and help email me :)
thanks ali sultan for send two screen short :)



share this post
Share to Facebook Share to Twitter Share to Google+ Share to Stumble Upon Share to Evernote Share to Blogger Share to Email Share to Yahoo Messenger More...

1 comments:

Anonymous said...

nice