Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi Everyone,
I have one serious problem,
if you have any solution please let me know.

I have one WPF bar chart.
I am creating this using below function.

C#
public Chart createwpfbar(Chart wpfbar)
        {
            DataPointSeries datapointseries = new ColumnSeries();
            datapointseries.Title = "Quantity";
            List<keyvaluepair><string,>> valueList = new List<keyvaluepair><string,>>();
            valueList.Add(new KeyValuePair<string,>("Developer", 60));
            valueList.Add(new KeyValuePair<string,>("Misc", 20));
            valueList.Add(new KeyValuePair<string,>("Tester", 50));
            valueList.Add(new KeyValuePair<string,>("QA", 30));
            valueList.Add(new KeyValuePair<string,>("Project Manager", 40));
            ChartLegendItem item1 = new ChartLegendItem();
            item1.MarkerFill = Brushes.YellowGreen;
            item1.Label = "Volts";
            ChartDefaultView chartdefaultview = new ChartDefaultView();
            chartdefaultview.ChartLegend.Items.Add(item1);
            chartdefaultview.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center;
            BarSeries newbarseries = new BarSeries();
            newbarseries.Title = "Volts";
            newbarseries.Title = Brushes.Red;
            datapointseries.DependentValueBinding = new Binding("Value");
            datapointseries.IndependentValueBinding = new Binding("Label");
            wpfbar.DataContext = valueList;
            return wpfbar;
        }

this function returns the WPF Bar chart.
after that for some reasons I am doing clone of Chart using below code.
C#
string GridXAML = XamlWriter.Save(element);
StringReader stringReader = new StringReader(GridXAML);
XmlReader xmlReader = XmlReader.Create(stringReader);
UIElement newGrid = (UIElement)XamlReader.Load(xmlReader);
ClipBoard.PushData(newGrid, element);

in this code I got one error for serialization,
error as follows,
Cannot serialize a non-public type 'System.Windows.Controls.DataVisualization.UniqueObservableCollection`1[System.Windows.Controls.DataVisualization.Charting.IAxis]'.

please help me as I am stucked with this error.

let me know if any solution for this.

Best Regards,
Amol P.Patil
Posted
Updated 20-Oct-12 5:19am
v2
Comments
AmolPatil19787 3-Nov-12 3:52am    
hi Everyone,
please help me as I didn't get any solution for this error.
please please.

best Regards,
Amol Patil

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900