RadCartesianChart: The property 'LabelStyle' was not found in type 'Telerik.Windows.Controls.Charting.Axis'

11 posts, 0 answers
  1. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 17 Apr 2012 Link to this post

    The RadCartesianChart control (or its axes) sometimes causes this exception (The property 'LabelStyle' was not found in type 'Telerik.Windows.Controls.Charting.Axis'.) or a similar exception (The property 'MajorTickStyle' was not found in type 'Telerik.Windows.Controls.Charting.Axis'.) to be thrown.

    The strange thing is that it seems to happen randomly. Simply reloading the webpage (i.e. reloading the Silverlight plugin) usually fixes the problem.

    I've tried setting these properties in several ways, both in xaml and code-behind. When in xaml, the exception is thrown during the  InitializeComponent() of the page. When in code-behind, it's thrown at startup of the application.

    I've not been able to reproduce it in a new project with a RadCartesianChart. Maybe the size of the project has something to do with it?

    Currently I'm adding the axes in code-behind like this (in the Loaded event of the chart):

    LinearAxis verticalAxis = new LinearAxis()
                {
                    Title = "",
                    Name = "MyVerticalAxis",
                    Style = App.Current.Resources["ChartCustomAxis"] as Style,
                    LabelStyle = App.Current.Resources["ChartLabel"] as Style
                };
                ChartJam.VerticalAxis = verticalAxis;
     
                DateTimeContinuousAxis horizontalAxis = new DateTimeContinuousAxis()
                {
                    Title = "",
                    Name = "MyHorizontalAxis",
                    PlotMode = Telerik.Charting.AxisPlotMode.OnTicks,
                    Style = App.Current.Resources["ChartCustomAxis"] as Style,
                    LabelStyle = App.Current.Resources["ChartLabel"] as Style,
                    LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate
                };
                ChartJam.HorizontalAxis = horizontalAxis;

    The styles are defines as follows:

    <Style x:Key="ChartCustomAxis" TargetType="telerik:Axis">
            <Setter Property="MajorTickStyle">
                <Setter.Value>
                    <Style TargetType="Rectangle">
                        <Setter Property="Fill" Value="#FFD7D7D7"/>
                        <Setter Property="Opacity" Value="0.3"/>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

    <Style x:Key="ChartLabel" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Margin" Value="1"/>
        </Style>

    Any help much appreciated.
  2. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 19 Apr 2012 Link to this post

    Even when I remove all charts from the project, the problem still occurs randomly (at startup) when I have the following code in one of the project's general ResourceDictionaries:

     
    ...
     
    <Style x:Key="ChartCustomAxis" TargetType="telerik:Axis">
            <Setter Property="MajorTickStyle">
                <Setter.Value>
                    <Style TargetType="Rectangle">
                        <Setter Property="Fill" Value="#FFD7D7D7"/>
                        <Setter Property="Opacity" Value="0.3"/>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

    How is this possible?
  3. DevCraft banner
  4. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 20 Apr 2012 Link to this post

    Hi Jeroen,

    We are sorry to hear that you are experiencing problems with our controls. We know that randomly-occuring errors are the most annoying of all.

    In this particular situation I have a hunch why this is happening. Currently we have two chart controls: RadChart (assembly Telerik.Controls.Charting) and RadChartView (assembly Telerik.Controls.Chart). Both of these assemblies have an Axis class. I guess that you have added both of the references to your project and this is the origins of the problem.

    1. I would suggest that you don't add both of these dlls. This should fix the problem.

    2. If you need both of these assemblies - I can suggest that you do not use the Telerik schema:
    but use the full name of the clr-namespace:
    <UserControl xmlns:radcharting="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
    xmlns:charting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" />
    for RadChart and:
    <UserControl xmlns:radchartview="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
        xmlns:chartview="clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart" />
     for the RadChartView.

    I apologize for all caused inconvenience. Let us know if this fixes the currently present issues.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 10 May 2012 Link to this post

    I've tried your 2nd suggestion and it seems to work fine now. Thanks!
  6. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 29 May 2012 Link to this post

    Unfortunately today I've encountered a problem again, in a version of my application where I've implemented the "fix". Again the error only happens sometimes. Usually simply reloading the webpage fixes the issue. 

    The exception now thrown is: Could not load file or assembly 'Telerik.Windows.Controls.Chart, Version=2012.1.326.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)

    In the xaml the only namespaces referenced are:
    xmlns:radchartview="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
    xmlns:chartview="clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart"

    The chart:
    <Border Margin="2,2,8,2" Grid.Column="0" Background="#33000000" >
      <Border.Resources>
        <Style x:Key="CustomAxis" TargetType="chartview:Axis">
          <Setter Property="LabelStyle">
            <Setter.Value>
              <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="1"/>
                <Setter Property="Foreground" Value="White" />
              </Style>
            </Setter.Value>
          </Setter>
          <Setter Property="MajorTickStyle">
            <Setter.Value>
              <Style TargetType="Rectangle">
                <Setter Property="Fill" Value="#FFD7D7D7"/>
                <Setter Property="Opacity" Value="0.3"/>
              </Style>
            </Setter.Value>
          </Setter>
        </Style>
      </Border.Resources>
      <radchartview:RadCartesianChart x:Name="ChartJam"
                                 MouseWheel="ChartJam_MouseWheel"
                                 MouseLeftButtonUp="ChartJam_MouseLeftButton"
                                 Loaded="ChartJam_Loaded"
                                 Height="Auto" MinHeight="100"
                                 Width="Auto" MinWidth="200"
                                                       >
     
        <radchartview:RadCartesianChart.VerticalAxis>
          <chartview:LinearAxis Title="" Style="{StaticResource CustomAxis}"
                                                        />
        </radchartview:RadCartesianChart.VerticalAxis>
     
        <radchartview:RadCartesianChart.HorizontalAxis>
          <chartview:DateTimeContinuousAxis
                                      PlotMode="OnTicks" Style="{StaticResource CustomAxis}"
                                      MajorStepUnit="{Binding MajorStepUnit}"
                                      MajorStep="{Binding MajorStep}"
                                      LabelFormat="{Binding LabelFormat}"
                                      Minimum="{Binding MinimumDateTime}"
                                      LabelFitMode="Rotate"
                                      Title=""
                                                                />
        </radchartview:RadCartesianChart.HorizontalAxis>
     
        <radchartview:RadCartesianChart.Behaviors>
          <chartview:ChartPanAndZoomBehavior ZoomMode="None"
                                             PanMode="None"/>
          <chartview:ChartTrackBallBehavior ShowIntersectionPoints="True"
                                          ShowTrackInfo="True"
                                          SnapMode="ClosestPoint" />
        </radchartview:RadCartesianChart.Behaviors>
     
        <chartview:AreaSeries ItemsSource="{Binding LineData}"
                            CategoryBinding="DtJamLength"
                            ValueBinding="JamLength"
                            StrokeThickness="1"
                            Stroke="#FF93D427"
                              Fill="#AA93D427"
                                                    >
          <chartview:AreaSeries.TrackBallInfoTemplate>
            <DataTemplate>
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Grid.ColumnSpan="2" FontWeight="Bold" HorizontalAlignment="Center"
                           Text="{Binding Labels.ChartLast24Hours, Source={StaticResource PublicLabels}}" />
                <TextBlock Grid.Row="1" Grid.Column="0" FontWeight="Bold"
                           Text="{Binding Labels.Timestamp, Source={StaticResource PublicLabels}, Converter={StaticResource StringToLabelConverter}}" />
                <TextBlock Grid.Row="1" Grid.Column="1"
                           Text="{Binding DataPoint.Category, StringFormat='dd/MM/yyyy HH:mm'}" />
                <TextBlock Grid.Row="2" Grid.Column="0" FontWeight="Bold"
                           Text="{Binding Labels.JamLength, Source={StaticResource PublicLabels}, Converter={StaticResource StringToLabelConverter}}" />
                <TextBlock Grid.Row="2" Grid.Column="1"
                           Text="{Binding DataPoint.Value,StringFormat=\{0:n2\}km}" />
              </Grid>
            </DataTemplate>
          </chartview:AreaSeries.TrackBallInfoTemplate>
     
        </chartview:AreaSeries>
     
        <radchartview:RadCartesianChart.Grid>
          <chartview:CartesianChartGrid MajorLinesVisibility="XY" IsTabStop="False">
            <chartview:CartesianChartGrid.YStripeBrushes>
              <SolidColorBrush Color="Pink" Opacity="0.9" />
              <SolidColorBrush Color="Transparent" />
            </chartview:CartesianChartGrid.YStripeBrushes>
            <chartview:CartesianChartGrid.XStripeBrushes>
              <SolidColorBrush Color="#FFD7D7D7" Opacity="0.3" />
              <SolidColorBrush Color="Transparent" />
            </chartview:CartesianChartGrid.XStripeBrushes>
          </chartview:CartesianChartGrid>
        </radchartview:RadCartesianChart.Grid>
     
      </radchartview:RadCartesianChart>
     
    </Border>



  7. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 30 May 2012 Link to this post

    Hi Jeroen,

    I have created a project based on the code that you have provided and I do not get any errors and I do not see any errors in the code.

    We need some more information on your current project. Are you also referencing the Charting assembly or only the Chart assembly? Can you please verify if all referenced Telerik assemblies have the same version. 

    The only thing that comes to my mind is that may be you have not referenced the Controls and Data assemblies (Telerik.Windows.Controls and Telerik.Windows.Data), so please check this.

    If this problem persists, I will have to ask that you open a support ticket and send us a project (which includes the binaries you use) that reproduces this exception, so that we can test and investigate the origins of this problematic behavior.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 30 May 2012 Link to this post

    Yes, I need both assemblies in my project.

    I've recently uninstalled RadControls and reinstalled to ensure I have the latest version and ONLY the this version.
    Every single referenced DLL has:
    Runtime = v4.0.30319
    Version = 2012.1.326.1050

    I'll try to reproduce it in a new project.
  9. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 01 Jun 2012 Link to this post

    Haven't been able to reproduce it in a small new project, but I'll keep trying...

    In the mean time, is it possible at all that this is somehow related to the 'Reduce XAP size by using application library caching' option?
  10. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 04 Jun 2012 Link to this post

    Hello,

    We can not be certain if the library caching could be the cause of this, but it is an option to explore. Can you force a reload of the dlls and let us know how it goes?

    Regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  11. Jeroen
    Jeroen avatar
    49 posts
    Member since:
    Feb 2012

    Posted 04 Jun 2012 Link to this post

    How do I do that?
  12. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 07 Jun 2012 Link to this post

    Hello Jeroen,

    As a start you can try to turn the option off. Give this a try and let us know how it goes. Also you can check the ClientBin folder and see if the xap file contains the proper dlls, with the proper version.

    Can you also provide a list (snapshot) of which assemblies you have referenced. You can double check if all the assemblies are present in the ClientBin and if they have the same version.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner