This is a migrated thread and some comments may be shown as answers.

{"Object reference not set to an instance of an object."} when hiding ticks on axis

7 Answers 232 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Cedric
Top achievements
Rank 1
Cedric asked on 21 Jul 2011, 11:33 AM
Hi,
I get an exception when i add theses lines in my xaml :
<telerik:ChartArea.AxisX>
    <telerik:AxisX x:Uid="telerik:AxisX_2"
            AxisLabelsVisibility="Collapsed"
            MajorTicksVisibility="Collapsed"
            MinorTicksVisibility="Collapsed" />
</telerik:ChartArea.AxisX>

If remove them the chart is correctly displayed. Is it the right manner to hide all the ticks ?
I want the lightest graph possible : only the bar with the value number in it, no legend, no title, no tick, nothing else,...

Any help ?

- Cedric -

Here are the complete files:

The Xaml:

and the code of the ViewModel:
public class MainViewModel : ViewModelBase
{
    public MainViewModel()
    {
        this.Items = new List<Item>()
    {
        new Item() 
        
            Level = 1, 
            Text ="AAAA"
            StatusGroup = new List<StatusPerformance>()
            {
                new StatusPerformance("Success", new List<Performance>() 
                {
                    new Performance() { Name="TMI", Count=76},
                    new Performance() { Name="TXT", Count=39}
                }),
                new StatusPerformance("Misrecognition", new List<Performance>() 
                {
                    new Performance() { Name="TMI", Count=15},
                    new Performance() { Name="TXT", Count=33}
                }),
                new StatusPerformance("Unknown", new List<Performance>() 
                {
                    new Performance() { Name="TMI", Count=62}
                })
            }
        },
        new Item() { Level = 2, Text ="BBBB"},
        new Item() { Level = 3, Text ="CCCC"},
        new Item() { Level = 4, Text ="DDDD"},
    };
    }
  
    public IList<Item> Items { get; private set; }
}
  
public class Item : ViewModelBase
{
    private TileStateEnum tileState;
    public int Level { get; set; }
    public string Text { get; set; }
    public TileStateEnum TileStateProp
    {
        get
        {
            return this.tileState;
        }
  
        set
        {
            if (this.tileState != value)
            {
                this.tileState = value;
                this.NotifyPropertyChanged("TileStateProp");
            }
        }
    }
  
    public List<StatusPerformance> StatusGroup { get; set; }
}
  
public class StatusPerformance : List<Performance>
{
    public StatusPerformance(string status, IList<Performance> performances)
    {
        this.Status = status;
        this.AddRange(performances);
    }
    public string Status { get; private set; }
}
  
public class Performance
{
    public string Name { get; set; }
    public int Count { get; set; }
}


7 Answers, 1 is accepted

Sort by
0
Cedric
Top achievements
Rank 1
answered on 21 Jul 2011, 01:45 PM
Seems there is a little probleme with the previous post.
Here is the Xaml:

<Window x:Class="TestTileView.MainWindow"
        xmlns:local="clr-namespace:TestTileView"
        Title="MainWindow"
        Height="350"
        Width="525">
    <Window.Resources>
        <local:FluidContentStateConverter x:Uid="conv:TileConverter_1"
                                          x:Key="FluidContentStateConverter" />
        <local:TileStateConverter x:Key="TileStateConverter" />
  
        <Style x:Uid="Style_17"
               TargetType="telerik:RadTileView"
               x:Key="TileGraphStyle">
            <Setter x:Uid="Setter_185"
                    Property="IsItemDraggingEnabled"
                    Value="True" />
            <Setter x:Uid="Setter_186"
                    Property="MaximizeMode"
                    Value="One" />
            <Setter x:Uid="Setter_187"
                    Property="IsItemsAnimationEnabled"
                    Value="False" />
            <Setter x:Uid="Setter_188"
                    Property="PreservePositionWhenMaximized"
                    Value="True" />
            <Setter x:Uid="Setter_189"
                    Property="telerik:TileViewPanel.IsVirtualized"
                    Value="True" />
            <Setter x:Uid="Setter_190"
                    Property="IsAutoScrollingEnabled"
                    Value="True" />
            <Setter x:Uid="Setter_191"
                    Property="TileStateChangeTrigger"
                    Value="SingleClick" />
            <Setter x:Uid="Setter_192"
                    Property="MinimizedColumnWidth"
                    Value="300" />
            <Setter x:Uid="Setter_193"
                    Property="MinimizedRowHeight"
                    Value="300" />
            <Setter x:Uid="Setter_194"
                    Property="MinimizedItemsPosition"
                    Value="Left" />
        </Style>
  
        <DataTemplate x:Key="LargeTemplate">
            <StackPanel Orientation="Horizontal"
                        DataContext="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadFluidContentControl, Mode=FindAncestor},  Path=DataContext}">
                <TextBlock Background="AliceBlue"
                           Text="This is LargeTemplate" />
                <TextBlock Background="AliceBlue"
                           Text="{Binding Text}" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="NormalTemplate">
            <StackPanel Orientation="Horizontal"
                        DataContext="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadFluidContentControl, Mode=FindAncestor},  Path=DataContext}">
                <TextBlock Background="Bisque"
                           Text="This is Normal" />
                <TextBlock Background="Bisque"
                           Text="{Binding Text}" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="SmallTemplate">
            <telerik:RadChart Name="chartTechnicalItemsMin"
                              Background="Transparent"
                              BorderThickness="0"
                              IsTabStop="False"
                              UseDefaultLayout="False"
                              DataContext="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadFluidContentControl, Mode=FindAncestor},  Path=DataContext}"
                              ItemsSource="{Binding StatusGroup}"
                              ToolTip="Display matching technical items by libraries"
                              x:Uid="chartTechnicalItemsMin">
                <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping x:Uid="telerik:SeriesMapping_16"
                                           CollectionIndex="0"
                                           ChartAreaName="ItemArea">
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:HorizontalStackedBarSeriesDefinition x:Uid="telerik:HorizontalStackedBarSeriesDefinition_1"
                                                                          ShowItemLabels="True" />
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping x:Uid="telerik:ItemMapping_31"
                                                 DataPointMember="YValue"
                                                 FieldName="Count" />
                            <!--<telerik:ItemMapping x:Uid="telerik:ItemMapping_32"
                                             DataPointMember="XCategory"
                                             FieldName="Name" />-->
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>
  
                    <telerik:SeriesMapping x:Uid="telerik:SeriesMapping_17"
                                           ChartAreaName="ItemArea"
                                           LegendLabel="Hesitation"
                                           CollectionIndex="1">
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:HorizontalStackedBarSeriesDefinition x:Uid="telerik:HorizontalStackedBarSeriesDefinition_2"
                                                                          ShowItemLabels="True" />
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping x:Uid="telerik:ItemMapping_33"
                                                 DataPointMember="YValue"
                                                 FieldName="Count" />
                            <!--<telerik:ItemMapping x:Uid="telerik:ItemMapping_34"
                                             DataPointMember="XCategory"
                                             FieldName="Name" />-->
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>
  
                    <telerik:SeriesMapping x:Uid="telerik:SeriesMapping_18"
                                           ChartAreaName="ItemArea"
                                           LegendLabel="Unknown"
                                           CollectionIndex="2">
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:HorizontalStackedBarSeriesDefinition x:Uid="telerik:HorizontalStackedBarSeriesDefinition_3"
                                                                          ShowItemLabels="True" />
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping x:Uid="telerik:ItemMapping_35"
                                                 DataPointMember="YValue"
                                                 FieldName="Count" />
                            <!--<telerik:ItemMapping x:Uid="telerik:ItemMapping_36"
                                             DataPointMember="XCategory"
                                             FieldName="Name" />-->
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>
  
                    <telerik:SeriesMapping x:Uid="telerik:SeriesMapping_19"
                                           ChartAreaName="ItemArea"
                                           LegendLabel="Misrecognition"
                                           CollectionIndex="3">
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:HorizontalStackedBarSeriesDefinition x:Uid="telerik:HorizontalStackedBarSeriesDefinition_4"
                                                                          ShowItemLabels="True" />
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping x:Uid="telerik:ItemMapping_37"
                                                 DataPointMember="YValue"
                                                 FieldName="Count" />
                            <!--<telerik:ItemMapping x:Uid="telerik:ItemMapping_38"
                                             DataPointMember="XCategory"
                                             FieldName="Name" />-->
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>
                </telerik:RadChart.SeriesMappings>
                <telerik:ChartArea x:Uid="chartArea"
                                   Name="ItemArea"
                                   NoDataString="Not available"
                                   FontSize="8">
                    <!--<telerik:ChartArea.AxisX>
                        <telerik:AxisX x:Uid="telerik:AxisX_2"
                                       AxisLabelsVisibility="Collapsed"
                                       MajorTicksVisibility="Collapsed"
                                       MinorTicksVisibility="Collapsed" />
                    </telerik:ChartArea.AxisX>
                    <telerik:ChartArea.AxisY>
                        <telerik:AxisY x:Uid="telerik:AxisY_2"
                                       AxisLabelsVisibility="Collapsed"
                                       MajorTicksVisibility="Collapsed"
                                       MinorTicksVisibility="Collapsed" />
                    </telerik:ChartArea.AxisY>-->
                </telerik:ChartArea>
                <telerik:RadChart.PaletteBrushes>
                    <SolidColorBrush x:Uid="SolidColorBrush_17"
                                     Color="#FF99CC00" />
                    <SolidColorBrush x:Uid="SolidColorBrush_18"
                                     Color="#FFFFCC00" />
                    <SolidColorBrush x:Uid="SolidColorBrush_19"
                                     Color="#FF999999" />
                    <SolidColorBrush x:Uid="SolidColorBrush_20"
                                     Color="#FFFF6702" />
                </telerik:RadChart.PaletteBrushes>
            </telerik:RadChart>
        </DataTemplate>
        <DataTemplate x:Key="RadFluidContentControlTemplate">
            <telerik:RadFluidContentControl ContentChangeMode="Manual"
                                            TransitionDuration="0:0:.5"
                                            LargeContentTemplate="{StaticResource LargeTemplate}"
                                            SmallContentTemplate="{StaticResource SmallTemplate}"
                                            ContentTemplate="{StaticResource SmallTemplate}"
                                            State="{Binding TileStateProp, Converter={StaticResource FluidContentStateConverter}}">
            </telerik:RadFluidContentControl>
        </DataTemplate>
  
        <Style TargetType="telerik:RadTileViewItem"
               x:Key="ItemContainerStyle">
            <Setter Property="TileState"
                    Value="{Binding TileStateProp, Mode=TwoWay, Converter={StaticResource TileStateConverter}}" />
        </Style>
    </Window.Resources>
    <Grid>
        <telerik:RadTileView x:Uid="tileView1"
                             x:Name="tileView1"
                             MaximizeMode="ZeroOrOne"
                             Style="{StaticResource TileGraphStyle}"
                             ContentTemplate="{StaticResource RadFluidContentControlTemplate}"
                             ItemContainerStyle="{StaticResource ItemContainerStyle}"
                             ItemsSource="{Binding Items}">
            <telerik:RadTileView.ItemTemplate>
                <DataTemplate x:Uid="DataTemplate_4">
                    <TextBlock x:Uid="TextBlock_11"
                               Text="{Binding Level}" />
                </DataTemplate>
            </telerik:RadTileView.ItemTemplate>
        </telerik:RadTileView>
    </Grid>
</Window>
0
Nikolay
Telerik team
answered on 26 Jul 2011, 09:35 AM
Hi Cedric,

We are aware of an issue concerning setting some properties when the chart is in a DataTemplate, however, we haven't been able to reproduce the error you have reported.

Attached is a sample application, based on the code snippets you've sent, which we have created to test this scenario. It demonstrates the issue I've mentioned as well - on the left side you can see the chart in a DataTemplate and on the right - outside of it. Setting the Minor and Major Ticks Visibility, as well as Axis Labels Visibility,  does not work out of the box in a scenario, in which the chart is placed in a DataTemplate, however, it does not throw the error you have reported.Please, have a look at the application to check whether you would still get the same error.In case you do, it would be very helpful for us if you're able to modify the test application so that the error is reproducible for our developers to investigate further and provide a fix.

As for the issue with not being able to set some properties in a chart palced within a DataTemplate, the work-around is to create a Loaded event on the chart and set the properties - you can find this work-around in the application as well - simply uncomment the code in the Loaded event handler ( in code behind ).

Regards,
Nikolay
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Cedric
Top achievements
Rank 1
answered on 26 Jul 2011, 03:21 PM
Hi Nokolai,
I reproduce the problem easily with your project : just use a TileView as i post in my sample. 
Replace the line :
<ContentControl ContentTemplate="{StaticResource SmallTemplate}" Content="{Binding Items}" Grid.Column="0" />
in your project by this one :
<telerik:RadTileView x:Uid="tileView1"
  Name="tileView1"
  MaximizeMode="ZeroOrOne"
  ContentTemplate="{StaticResource RadFluidContentControlTemplate}"
  ItemsSource="{Binding Items}">
        </telerik:RadTileView>
The RadFluidContentControlTemplate is in my previous post
and don't forget to rebind the datacontext on the radchart because it is not inherited as i point out in another post :
<telerik:RadChart Name="chartTechnicalItemsMin"
                             DataContext="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadFluidContentControl, Mode=FindAncestor},  Path=DataContext}"

Without the TileView+FluidContentControl all is fine ....

- Cedric -
0
Nikolay
Telerik team
answered on 28 Jul 2011, 09:21 AM
Hi Cedric,

Please, find attached a modified version of the sample project which now includes TileView and FluidContentControl. The Minor and Major Ticks, as well as the Axis Label are collapsed ( from the Loaded event ), yet still no error message is thrown. Could you, please, have a look at it and see if it works for you as well, or whether we're missing something else from your scenario.

Greetings,
Nikolay
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Cedric
Top achievements
Rank 1
answered on 28 Jul 2011, 10:23 AM
Hi Nikolai,
I just download you modified project, change the .Net target Framework to 4.0, Run and Kaboom !!!
My Telerik.Windows.Controls.Charting dll version is 2011.1.627.40, may be you can test with this version ?
Which ones are you using ?

- Cedric -
0
Accepted
Nikolay
Telerik team
answered on 28 Jul 2011, 10:43 AM
Hello Cedric,

I have been testing using the official Q2 release assemblies ( version 2011.2.712 ), which is obviously where the difference is. The issue you've encountered in the 2011.1.627 assemblies has been fixed for the Q2 release. I am attaching the assemblies I have been using to test this scenario, which I suppose would work for you as well. You would need to download and update to Q2 in order to get the permanent fix.

All the best,
Nikolay
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Cedric
Top achievements
Rank 1
answered on 28 Jul 2011, 11:23 AM
I can confirm that with your dll i have no more problems, I manage to update to the Q2.

Thanks

- Cedric -
Tags
Chart
Asked by
Cedric
Top achievements
Rank 1
Answers by
Cedric
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or