I am working on a project that takes some basic controls and some telerik wpf controls, places them on a canvas, and saves these for redisplay later. All of the controls are generated at runtime.
Whenever I attempt to save the Xaml of a RadChart, after approximately 30 seconds, the XamlWriter.Save method throws a StackOverflow exception. The problem is reproducible.
Create project referencing the .NET Framework 4.
Telerik.Window.Controls
Telerik.Window.Controls.Chart
Telerik.Window.Controls.Charting
Telerik.Window.Controls.Data
Telerik.Window.Controls.DataVisualization
Telerik.Window.Data
Place the following code on a new window:
<
Canvas
Name
=
"testCanvas"
Height
=
"350"
Width
=
"525"
>
<
telerik:RadChart
Name
=
"testChart"
Height
=
"350"
Width
=
"525"
/>
</
Canvas
>
Place this in code-behind:
public
MainWindow()
{
InitializeComponent();
this
.PreviewMouseDoubleClick += Window_PreviewMouseDoubleClick;
testCanvas.Loaded += testCanvas_Loaded;
}
private
void
testCanvas_Loaded(
object
sender, RoutedEventArgs e)
{
testChart.DefaultView.ChartLegend.UseAutoGeneratedItems =
true
;
Telerik.Windows.Controls.Charting.DataSeries barSeries =
new
Telerik.Windows.Controls.Charting.DataSeries();
barSeries.LegendLabel =
"Expenses"
;
barSeries.Definition =
new
Telerik.Windows.Controls.Charting.BarSeriesDefinition();
barSeries.AddRange(
new
List<Telerik.Windows.Controls.Charting.DataPoint> {
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 45, XCategory =
"Jan"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 48, XCategory =
"Feb"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 53, XCategory =
"Mar"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 41, XCategory =
"Apr"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 32, XCategory =
"May"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 28, XCategory =
"Jun"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 63, XCategory =
"Jul"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 74, XCategory =
"Aug"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 77, XCategory =
"Sep"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 85, XCategory =
"Oct"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 89, XCategory =
"Nov"
},
new
Telerik.Windows.Controls.Charting.DataPoint() { YValue = 80, XCategory =
"Dec"
}
});
testChart.DefaultView.ChartArea.DataSeries.AddRange(
new
List<Telerik.Windows.Controls.Charting.DataSeries> { barSeries });
}
private
void
Window_PreviewMouseDoubleClick(
object
sender, MouseButtonEventArgs e)
{
var fileName = @
"c:\temp\tester.xaml"
;
using
(var fs =
new
FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
using
(var xw =
new
XmlTextWriter(fs, System.Text.Encoding.UTF8))
{
xw.Formatting = Formatting.Indented;
xw.Indentation = 4;
xw.IndentChar =
' '
;
//place breakpoint here
XamlWriter.Save(testCanvas, xw);
}
}
Run project and then double-click the window. At the "XamlWriter.Save(testCanvas, xw)", a stackoverflow exception will eventually occur
Please let me know what I can do to correct this issue.
Thanks