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

  • Home
  • SEARCH
  • 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 6773351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:39:29+00:00 2026-05-26T15:39:29+00:00

I have a line series chart called lineSeries1. I would like that chart to

  • 0

I have a line series chart called “lineSeries1”.

I would like that chart to be filled and updated during runtime, depending of two variables. “currentPos” would be the X axis, and “budget” would be the Y axis. Also, “budget” is possible to change value during runtime.

Basically, I would just like to know how to set values in the chart, programmatically. For example, whenever a new currentPos/budget is created, or when an existing budget is modified.

How can I pull that off in Silverlight C#? there is very little documentation on that online…

EDIT: after some research, I came upon this tutorial: http://www.a2zdotnet.com/View.aspx?Id=136. With some inspiration from that site, I came up with my own code, which doesn’t work…

Here’s my XAML:

<toolkit:Chart x:Name="theChart">

        <toolkit:LineSeries x:Name="lineSeries1" DependentValuePath="CurrentPos" IndependentValuePath="Budget"></toolkit:LineSeries>

    </toolkit:Chart>

Here’s my class:

public class oneEvent
{
    private int _CurrentPos;
    private int _Budget;

    public oneEvent(int currentPos, int budget)
    {
        _CurrentPos = currentPos;
        _Budget = budget;
    }

    public int CurrentPos
    {
        get { return _CurrentPos; }
        set { _CurrentPos = value; }
    }

    public int Budget
    {
        get { return _Budget; }
        set { _Budget = value; }
    }
}

and here’s my code which populates the lines chart:

public MainPage()
    {
        InitializeComponent();

        List<oneEvent> list = new List<oneEvent>();
        list.Add(new oneEvent(0, 8000));
        list.Add(new oneEvent(1, 9000));
        list.Add(new oneEvent(2, 10000));
        list.Add(new oneEvent(3, 11000));
        list.Add(new oneEvent(4, 12000));
        list.Add(new oneEvent(5, 9000));
        list.Add(new oneEvent(6, 500));
        list.Add(new oneEvent(7, 1000));

        try
        {
            lineSeries1.ItemsSource = list;
        }
        catch (System.Exception excep)
        {
            MessageBox.Show(excep.Message);
        }
    }

When I run this, I get a message box saying “object reference not set to an instance of an object”. What am I doing wrong?

EDIT:
ok, figured out my problem.
Instead of writing lineSeries1.ItemsSource = list;,
I should’ve written LineSeries lineseries = theChart.Series[0] as LineSeries;
lineseries.ItemsSource = list;

I don’t know why, but it works…

  • 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-26T15:39:30+00:00Added an answer on May 26, 2026 at 3:39 pm

    ok, figured out my problem. Instead of writing

    lineSeries1.ItemsSource = list;

    , I should’ve written

    LineSeries lineseries = theChart.Series[0] as LineSeries;
    lineseries.ItemsSource = list;

    I don’t know why, but it works…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chart that I would like to update whenever a form on
I have a form that has a series of check boxes and some line
I have a line of C# in my ASP.NET code behind that looks like
I have a SQL function called get_forecast_history(integer,integer) that takes two arguments, a month and
I have a chart with a series that denotes a large set (1000's) of
I am trying to plot two lines series on a chart. Each line with
I have multiple line series in a chart. Chart lines are drawn first and
I have a line chart with multiple series in 4.02. At different points the
I have a series of line graphs in a jqPlot chart. What I want
In a text file I will have a line containing a series of numbers,

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.