Link to home
Start Free TrialLog in
Avatar of chester427
chester427Flag for United States of America

asked on

How do I remove the legend from a Silverlight 4 PieSeries Pie Chart

I have created a Chart using a PieSeries in Silverlight 4 via c# code.  I need to remove the legend (via code).  Nothing I have tried has worked, any suggestions?
Avatar of politex
politex

Hi, it's dirty hack, but works:
myChart.LegendStyle.Setters.Add(new Setter(HeightProperty, 0));
myChart.LegendStyle.Setters.Add(new Setter(WidthProperty, 0));

Open in new window

Avatar of chester427

ASKER

Thanks for responding Politex, but I get a null reference exception.  I had tried something similar with the PieSeries that is attached to the chart by creating a stye and setting the LegendItem.HeightProperty and LegenItem.WidthProperty to 0 (with a setter) and then assigning the style object to the PieSeries.  This worked fine, but only removed(hid) the items from the legend - it still left an empty legend - basically a gray box.  Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of politex
politex

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for posting the example.  I was just missing a reference.  After adding it -it all fell into place.

Super!
I appreciated the help I received.  Politex, thanks for the help.