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 648527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:50:34+00:00 2026-05-13T21:50:34+00:00

I am using the Silverlight WriteableBitmap command to render a ‘Pie Chart’ using the

  • 0

I am using the Silverlight WriteableBitmap command to render a ‘Pie Chart’ using the following code.

    Chart GetChart()
    {
        Chart newChart = new Chart() { Width = 100.0, 
                                       Height = 100.0  };

        PieSeries pieSeries = new PieSeries();
        pieSeries.SetBinding(PieSeries.ItemsSourceProperty, new Binding());
        pieSeries.DependentValueBinding = new Binding("Value");
        pieSeries.IndependentValueBinding = new Binding("Key");
        pieSeries.AnimationSequence = AnimationSequence.FirstToLast;
        pieSeries.IsSelectionEnabled = true;
        newChart.Series.Add(pieSeries);

        newChart.SetValue(Chart.DataContextProperty, new KeyValuePair<string, int>[] 
                            {
                                new KeyValuePair<string, int>("Work", 9), 
                                new KeyValuePair<string, int>("Driving", 2), 
                                new KeyValuePair<string, int>("Family", 4), 
                                new KeyValuePair<string, int>("Sleep", 8), 
                                new KeyValuePair<string, int>("Friends", 1) 
                            });
        return newChart;
    }

    WriteableBitmap bmapPreviewCanvas = new WriteableBitmap(GetChart, null);

The result I was expecting is a Bitmap with a PieChart. What I got was a Bitmap with the background without any PieChart.

Question is : What should I do to get the Pie Chart rendered in the variable ‘bmapPreviewCanvas’?

Edit : Does this have something to do with the ANIMATIONSEQUENCE ?

  • 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-13T21:50:34+00:00Added an answer on May 13, 2026 at 9:50 pm

    I believe your problem is that the instance of the Chart control you are trying to create a bitmap of is not on the visual tree.

    I have not actually tried this myself, but I believe that you have to explicitly use the Render() method of the WritableBitmap class if the UIElement is not part of the visual tree. You will also have to call InvalidateMeasure() on the element before calling Render(), and Invalidate() on the WritableBitmap afterward to actually render the bitmap.

    From the MSDN documentation:

    After calling this method, you must call Invalidate in order to render the bitmap.

    This method does support UIElement objects that are not part of the visual tree. You are required to call Measure and Arrange for UIElement objects that are not in the visual tree, before calling Render.

    I would try the following instead:

    var chart = GetChart();
    chart.InvalidateMeasure();
    WriteableBitmap bmapPreviewCanvas = new WriteableBitmap(chart.Width, chart.Height);
    bmpaPreviewCanvas.Render(chart, null);
    bmapPreviewCanvas.Invalidate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 472k
  • Answers 472k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer for k,v in sorted(opt_dict.items(), key = lambda item: int(item[0][len("option"):]) if… May 16, 2026 at 3:39 am
  • Editorial Team
    Editorial Team added an answer To Whom It May Concern: I completely removed and recreated… May 16, 2026 at 3:39 am
  • Editorial Team
    Editorial Team added an answer You can use order by with 2 field. This should… May 16, 2026 at 3:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.