I'm trying to create a 2 line chart subtitle. I can embed a linefeed in the title string and I get two lines. The entire subtitle is centered in the graph but the first line is left justified. Is there any way to horizontally center both lines. I tried looking for a template I could modify but was unsuccessful.
Hello Bob,
To get this to work in C# code-behind, you can use the following code, where “chart” is the XamDataChart:
TextBlock.SetTextAlignment(chart, TextAlignment.Center);
Please let me know if you have any other questions or concerns on this matter.
Thank you very much, your answer works perfectly if I create the DataChart in xaml. I can't figure out how to make it work when I create the chart in c# code behind. Any ideas?
I believe this is happening because the Subtitle of the XamDataChart is a single TextBlock control that by default is horizontally centered. This does not include its text alignment though. It appears that you can change this by setting the attached TextBlock.TextAlignment property on the XamDataChart to “Center” like so:
<ig:XamDataChart TextBlock.TextAlignment="Center">
I hope this helps. Please let me know if you have any other questions or concerns on this matter.