Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7418307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:51:45+00:00 2026-05-29T07:51:45+00:00

Using the Silverlight 4 toolkit chart control, I am trying to create a chart

  • 0

Using the Silverlight 4 toolkit chart control, I am trying to create a chart 100% at runtime with no evidence of it anywhere in the XAML. To do so, I create the blank chart when the page loads:

        Chart TrendChart = new Chart();
        TrendChart.Name = "TrendChart";
        TrendChart.Title = "Call History";
        TrendChart.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
        TrendChart.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
        TrendChart.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
        TrendChart.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;

        GridPanel.Children.Add(TrendChart);

After the user clicks on a button to retrieve data, a List is created of this custom class:

    private class PhoneTrendDataPoint
    {
        public string XValue { get; set; }
        public double YValue { get; set; }
    }

I use that List, called CurrentCallTrends, as an ItemsSource for my chart.

        // Update the chart with the received data
        Chart TrendChart = (Chart)this.FindName("TrendChart");

        // Wipe out previous chart data
        TrendChart.Series.Clear();



        // set the data
        ColumnSeries columnSeries = new ColumnSeries();
        columnSeries.Name = "Current Call Volume";
        columnSeries.ItemsSource = CurrentCallTrends;
        //columnSeries.SetBinding(ColumnSeries.ItemsSourceProperty, new Binding("CurrentCallTrends"));
        columnSeries.DependentValueBinding = new Binding("XValue");
        columnSeries.IndependentValueBinding = new Binding("YValue");
        TrendChart.Series.Add(columnSeries);

The problem is that I get a runtime error where it prompts me to open a debugger regarding an object reference not set to an instance of an object. If I comment the line to .SetBinding then the ItemsSource vanishes and no data shows up, but at least there is no runtime error.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:51:46+00:00Added an answer on May 29, 2026 at 7:51 am

    After additional Googling, I made some modifications that seem to work but don’t strike me as the best way to go about doing this. Data now shows up, but I will not accept this as the answer unless there is no better method:

            // Update the chart with the received data
            Chart TrendChart = (Chart)this.FindName("TrendChart");
    
            // Wipe out previous chart data
            TrendChart.Series.Clear();
    
    
            // test data
            KeyValuePair<string, double>[] CurrentCallData = new KeyValuePair<string, double>[CurrentCallTrends.Count];
            for (int i = 0; i < CurrentCallTrends.Count; i++)
            {
                CurrentCallData[i] = new KeyValuePair<string, double>(CurrentCallTrends[i].XValue, CurrentCallTrends[i].YValue);
            }
    
    
    
            // set the data
            ColumnSeries columnSeries = new ColumnSeries();
            columnSeries.Name = "CurrentCallVolume";
            columnSeries.Title = "Current Call Volume";
            columnSeries.SetBinding(ColumnSeries.ItemsSourceProperty, new Binding());
            //columnSeries.ItemsSource = CurrentCallTrends;
            columnSeries.ItemsSource = CurrentCallData;
            columnSeries.DependentValueBinding = new Binding("Value");
            columnSeries.IndependentValueBinding = new Binding("Key");
            TrendChart.Series.Add(columnSeries);
    
            //this.DataContext = CurrentCallTrends;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Silverlight Control Toolkit and trying to position the legend below the
I am using the silverlight toolkit lineseries control and want to get rid of
I'm using the ContextMenu control from the Silverlight Toolkit, and I'd like to define
I'm trying to work with the LongListSelector control from the WP7 Silverlight Toolkit. It's
I'm using the Silverlight Toolkit DatePicker control. If an user enters an invalid format
I'm using the TreeView component from the Silverlight toolkit and I'm trying to get
I have a applied one of the Silverlight Toolkit themes to my XAML page,
I am using the Hubtile Control provided in the Silverlight toolkit ( August) and
We're using silverlight on our SharePoint site. When someone navigates to the page containing
I'm using silverlight and I defined two styles for the page: ExpanderBottomRightButtonStyle ExpanderScaleStyle Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.