What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 30624 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > how to bind xml data to windows phone chart ...
Srujana

how to bind xml data to windows phone chart

Replies: 3 | Posted by: Srujana on 7/18/2012 | Category: C# Forums | Views: 443 | Status: [Member] | Points: 10  


Hi,

I need to bind web-service returned xml data to windows phone bar chart,

I wrote the following code but the chart is displayed as empty,

can anybody help me in this.

C#:


private void client_GetStudentPerformanceChartCompleted(object sender,ServiceReference1.GetStudentPerformanceChartCompletedEventArgs e)
{
XElement xmlNews = XElement.Parse(e.Result.ToString());

BarSeries series = new BarSeries();

series.ItemsSource = from item in xmlNews.Descendants("SyllabusDetails")
select new Institute
{
Adress = item.Element("SubjectName").Value,

year = item.Element("ResultedMarks").Value
};
}

XAML:

<charting:Chart Foreground="Blue" x:Name="seriesChart" Background="Black">
<charting:BarSeries DependentValueBinding="{Binding year}" IndependentValueBinding="{Binding Adress}" Foreground="Pink" Background="Black" />
</charting:Chart>


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ranjeet_8
Ranjeet_8  
Posted on: 7/18/2012 8:14:36 AM
Level: Gold | Status: [Member] | Points: 25

Srujana, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Srujana
Srujana  
Posted on: 7/19/2012 1:53:12 AM
Level: Starter | Status: [Member] | Points: 25

Hi,
thanks for giving the reply,I am not using MVVM,
I wrote the code as follows,
class:
public class Chart
{
#region Properties
public string name { get; set; }
public int marks { get; set; }
#endregion
#region Constructors
public Chart(string Name, int Marks)
{
name = Name;
marks = Marks;

}
#endregion


}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
loginid = StudentPerformance.loginId;
examname = StudentPerformance.examname;
examtypeid = StudentPerformance.examtypeid;
client.GetStudentPerformanceChartCompleted+=new EventHandler<GetStudentPerformanceChartCompletedEventArgs>(client_GetStudentPerformanceChartCompleted);
client.GetStudentPerformanceChartAsync(loginid, examname, examtypeid);


}
private void client_GetStudentPerformanceChartCompleted(object sender,ServiceReference1.GetStudentPerformanceChartCompletedEventArgs e)
{
XElement xmlNews = XElement.Parse(e.Result.ToString());
var results = from item in xmlNews.Descendants("SyllabusDetails")
select new Chart((string)item.Element("SubjectName"),
(int)item.Element("ResultedMarks"));
// BarSeries a = new BarSeries();//when I using this ?I got empty chart
//a.ItemsSource = results;

}
XAML:

<charting:Chart Foreground="Blue" x:Name="seriesChart" Background="Black">
<charting:BarSeries Name="BarChart" ItemsSource="{StaticResource result}" DependentValuePath="marks" IndependentValuePath="name" Foreground="Pink" Background="Black" />
</charting:Chart>

and I got an error in xaml as the resource result could not be resolved.

Srujana, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Srujana
Srujana  
Posted on: 7/19/2012 3:24:38 AM
Level: Starter | Status: [Member] | Points: 25

Hi,
I got the solution from this link http://app.eschooltrack.com/Reports/Student_Performance.aspx?pi=bA26ilWlCbBbrQ3CeCw5VA==,
but can I bind multiple dependent values to the single chart with different colors.

Srujana, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 5:53:52 PM