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

'-1' is not a valid value for property 'Height'.

2 Answers 257 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Darlene asked on 31 Jul 2012, 09:25 PM

So, I blew up your ChartView by having fun with animating heights.  In my live application, I have two ChartViews on different rows of a Grid and the row heights are animated to show/collapse a chart.  If the window size is small enough, I will get a  "'-1' is not a valid value for property 'Height'." exception with this stack trace:
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.FrameworkElement.set_Height(Double value)
at Telerik.Windows.Controls.ChartView.PresenterBase.ArrangeUIElement(FrameworkElement presenter, RadRect layoutSlot, Boolean setSize) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Common\PresenterBase.cs:line 297
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateYStripes() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 479
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateVisuals(ChartLayoutContext context) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 421
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateUICore(ChartLayoutContext context) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 296

I have been able to reproduce this issue in its own project by forcefully setting the chart Height property to a small value and then adding a series (line/bar doesn't matter).  This is done in a Command executed by pressing a button.  Here is the relevant reproduction code:

<Window x:Class="TinyChart.MainWindow"
        xmlns:telerik="" Title="MainWindow" Height="350" Width="525">
            <RowDefinition Height="*" />
    <telerik:RadCartesianChart x:Name="chart" telerik:StyleManager.Theme="Metro">
            <Style TargetType="telerik:TrackBallInfoControl">
                <Setter Property="HeaderTemplate">
                            <TextBlock Text="{Binding}" Foreground="Black" HorizontalAlignment="Center"/>
            <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True" ShowTrackInfo="True" SnapMode="AllClosePoints" />
            <telerik:DateTimeCategoricalAxis LabelFormat="dd MMM yyyy" Title="Date Processed" DateTimeComponent="DayOfYear" LabelFitMode="Rotate" LabelInterval="3" LastLabelVisibility="Visible">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding}" HorizontalAlignment="Center" />
            <telerik:LinearAxis Title="# Documents Processed" />
            <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" />
        <Button Command="{Binding MyCommand}" Width="64" Height="64" VerticalAlignment="Top" HorizontalAlignment="Right" Content="..." />

View Model:

public class MainWindowViewModel
        public ObservableCollection<Item> Items { get; set; }
        public ICommand MyCommand { get; set; }
        public MainWindow View { get; set; }
        public MainWindowViewModel()
            MyCommand = new RelayCommand(OnMyCommand);
            Items = new ObservableCollection<Item>();
            Items.Add(new Item { Date = DateTime.Now, Number = 1 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(1), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(2), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(3), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(4), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(5), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(6), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(1), Number = 1 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(7), Number = 0 });
        private void OnMyCommand()
            View.chart.Height = 100;
            View.chart.Series.Add(new BarSeries
                            //StrokeThickness = 4,
                            //Stroke = Brushes.Red,
                            ItemsSource = Items,
                            CategoryBinding = new PropertyNameDataPointBinding("Date"),
                            ValueBinding = new PropertyNameDataPointBinding("Number"),
                            ShowLabels = false
    public class Item
        public DateTime Date { get; set; }
        public int Number { get; set; }
        public override string ToString()
            return Date.ToString() + " - " + Number.ToString();

I require this situation to work.  Although it may seem silly to set height before adding a series, this should not cause a crash.  If a workaround can't be found, I will require a hotfix.  This occurs with the latest version Q2 2012 SP1 (also Q1 2012).

The series is added after user invokes a command, so I know what data to display.  There can be multiple series in a chart also, hence the programmatic approach.

I am at a loss to figure out how to solve this problem as I can find nothing wrong with my code and it works fine when the screen size is sufficiently large enough.

Thank you very much!

2 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 01 Aug 2012, 01:48 PM
n/m.  I set MinHeight = 150 and put a ScrollViewer around the screen and that seems to have solved the issue.  It still shouldn't crash in this situation howeever.
Petar Kirov
Telerik team
answered on 03 Aug 2012, 10:22 AM

The issue you are reporting is indeed a bug, which I reproduced with 2012 Q2 SP1 (2012.2.725).
Fortunately the bug is fixed in the latest internal build - 2012.2.730. 

You can give it a try.

Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question