AxisLineStyle causing XamlParseException

7 posts, 0 answers
  1. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 01 Dec 2009 Link to this post


    I'm in need of some assistance regarding customizing certain properties of the RadChart control for Silverlight 3.

    I am using
    • Silverlight 3.0.40818.0
    • OS: Windows 7 Ultimate 32bit
    • Mozilla Firefox Version 3.5.5
    • Telerik RadChart from Telerik RadControls for Silverlight (RadControls_for_Silverlight_2009_2_701_DEV.msi and used to install - hope this is accurate enough)
    • preferred programming language: C#.Net

    My question is regarding styling the chart. I have used examples on this website to complete the code below. I'm creating a radchart, setting some default options (from the original project where i found this problem) and setting the ItemsSource to a basic array in codebehind. I am now attempting to change the styles of the x-axis/labels and y-axis/labels as well as the background of the chart.

    I managed to get the background to white by setting  background=white in XAML and the labels to black by using templates in XAML and setting it in codebehind:

    XAML (MainPage.xaml):
    <UserControl x:Class="SilverlightApplication2.MainPage" 
        xmlns:d="" xmlns:mc="" 
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" 
      <Grid x:Name="LayoutRoot"
                <Style x:Key="CustomItemLabelStyle" TargetType="TextBlock"
                    <Setter Property="Foreground" Value="Black" /> 
                <Style x:Key="CustomAxisLineStyle" TargetType="Line"
                    <Setter Property="Stroke" Value="Black" /> 
            <telerik:RadChart x:Name="ValuesChart" Background="White"
                <!-- Set Default Series Definition: --> 
                    <chart:LineSeriesDefinition ShowItemLabels="False" ShowPointMarks="False"
                <!-- Set Default Series Definition --> 
                    <chart:ChartDefaultView > 
                            <chart:ChartArea > 
                                    <chart:AxisY Step="5" /> 
                                    <chart:AxisX LabelStep="20" /> 
                            <chart:ItemMapping DataPointMember="YValue" /> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                        <GradientStop Color="Black" Offset="0"/> 
                        <GradientStop Color="White" Offset="1"/> 

    C# (Mainpage.xaml.cs):

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Net; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Documents; 
    using System.Windows.Input; 
    using System.Windows.Media; 
    using System.Windows.Media.Animation; 
    using System.Windows.Shapes; 
    namespace SilverlightApplication2 
        public partial class MainPage : UserControl 
            public MainPage() 
                int[] intarray = new int[10]; 
                intarray[0] = 3; 
                intarray[1] = 1; 
                intarray[2] = 5; 
                intarray[3] = 8; 
                intarray[4] = 5; 
                intarray[5] = 3; 
                intarray[6] = 2; 
                intarray[7] = 9; 
                intarray[8] = 3; 
                intarray[9] = 0; 
                ValuesChart.ItemsSource = intarray; 
                SolidColorBrush black = new SolidColorBrush(Colors.Black); 
                ValuesChart.DefaultView.ChartTitle.Foreground = black; 
                ValuesChart.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = this.LayoutRoot.Resources["CustomItemLabelStyle"as Style; 
                ValuesChart.DefaultView.ChartArea.AxisY.AxisStyles.ItemLabelStyle = this.LayoutRoot.Resources["CustomItemLabelStyle"as Style; 
                //ValuesChart.DefaultView.ChartArea.AxisX.AxisStyles.AxisLineStyle = this.LayoutRoot.Resources["CustomAxisLineStyle"] as Style; 
                //ValuesChart.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle = this.LayoutRoot.Resources["CustomAxisLineStyle"] as Style; 

    This works correctly without any exception or error. The result is a radchart in default cyan colour on a white background with black labels. The X and Y axis are still drawn in white (therefore invisible), and since you can see i have made no attempt to style them in this build as the code is commented out.

    When i remove the comments on either of the lines,
                //ValuesChart.DefaultView.ChartArea.AxisX.AxisStyles.AxisLineStyle = this.LayoutRoot.Resources["CustomAxisLineStyle"] as Style; 
    //ValuesChart.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle = this.LayoutRoot.Resources["CustomAxisLineStyle"] as Style; 

    when trying to run the project,
    • In my original attempt in a complex environment, I experienced simply a white screen on load, without any explanation.
    • Upon recreating this as shown above in a separate new project, I have been shown the following exception by visual studio:

    {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
       at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
       at System.Windows.FrameworkElement.set_Style(Style value)
       at Telerik.Windows.Controls.Charting.Axis2D.ApplyUserDefinedStyle()
       at Telerik.Windows.Controls.Charting.Axis2D.LogicalParentUserStyleChanged(Object sender, UserStyleChangedEventArgs e)
       at Telerik.Windows.Controls.Charting.Axis.OnAxisStyleChanged(String userStyleName)
       at Telerik.Windows.Controls.Charting.Axis.AxisStylesPropertyChanged(Object sender, PropertyChangedEventArgs e)
       at Telerik.Windows.Controls.Charting.AxisStyles.OnPropertyChanged(PropertyChangedEventArgs args)
       at Telerik.Windows.Controls.Charting.AxisStyles.OnPropertyChanged(String propertyName)
       at Telerik.Windows.Controls.Charting.AxisStyles.set_AxisLineStyle(Style value)
       at SilverlightApplication2.MainPage..ctor()}

    Am I doing something wrong here? This seems to be a very simple task that is very hard for me to accomplish! my apologies if i've missed something stupid, but I can't get this to work.

    Ideally I'd like to style the control further and might modify the templates, (which I will need to read up on how to edit) but this should be possible without templates for now.
  2. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 01 Dec 2009 Link to this post

    I have found that I am probably using RadControls for Silverlight Q2 and not RadControls for Silverlight Q3 - I'm going to doublecheck this and attempt to update and let you know how this goes over the next few minutes.
  3. DevCraft R3 2016 release webinar banner
  4. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 01 Dec 2009 Link to this post

    This problem seems to have been solved in Q3.

    Sorry to waste everyone's time!
  5. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 06 Dec 2009 Link to this post

    I googled my problem, having solved it, and found this posting to be the top result. For anyone revisiting this problem, I would like to point out that the syntax i was using was updated to make it a lot more readable and there IS a syntax which will work in Q2 as well! I was using the new syntax on the older version.

    Luckily I found a resource in Telerik support that showed the differences between old and new syntax.

    For information on how to style the radchart axes and the rest of the chart control you can use the following link:

    Thank you Telerik!
  6. Reuben
    Reuben avatar
    17 posts
    Member since:
    Apr 2009

    Posted 02 Feb 2010 Link to this post

    Pardon my rudeness but that last post is only semi-useful.  Where is the link that shows the differences between Q2 and Q3 syntax?
  7. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 04 Feb 2010 Link to this post

    Hello Reuben,

    Check the changes and backwards compatibility topic here:


  8. Zero Gravity Chimp
    Zero Gravity Chimp avatar
    40 posts
    Member since:
    Dec 2009

    Posted 04 Feb 2010 Link to this post


    Thanks for that!


Back to Top
DevCraft R3 2016 release webinar banner