Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
Custom Series with custom data object bindings not working.
posted

Hello,

I am implementing a custom series inherited from ": series", and I am trying to pass in more than a single collection of data points. The use case is that one of the data collections is actual data to graph and the second defines several "zones" on the graph that will have different coloring and annotations.

This is the XAML for my custom chart with custom series:

        <ProfileChart:ProfileChart Grid.Row="0"
                                   x:Name="Chart2"
                                   Margin="0,-17,20,37"
                                   VerticalAlignment="Stretch"
                                   HorizontalAlignment="Stretch">
            <ProfileChart:ProfileChart.Axes>
                <ig:NumericXAxis x:Name="xAxis" MinorStrokeThickness="0" MajorStrokeThickness="0" Visibility="Visible"/>
                <ig:NumericYAxis x:Name="yAxis" MinimumValue="-60" MaximumValue="350" MinorStrokeThickness="0" MajorStrokeThickness="0"/>
            </ProfileChart:ProfileChart.Axes>
            <ProfileChart:ProfileChart.Series>
                <ProfileChart:ProfileChartSeries ItemsSource="{StaticResource data}"
                                                 XAxis="{Binding ElementName=xAxis}"
                                                 YAxis="{Binding ElementName=yAxis}"
                                                 ZoneItems="{Binding Source=zoneData}"
                                                 TemperatureData="{Binding Source=temperatureData}"
                                                 />
            </ProfileChart:ProfileChart.Series>
        </ProfileChart:ProfileChart>

within the "ProfileChartSeries" I am attempting to pass in the ItemSource, as well as "ZoneItems" and "Temperature" data. The property code for these in my custom series class is the following:

        #region Property - ZoneItems
        public const string ZoneItemsPropertyName = "ZoneItems";
        public static readonly DependencyProperty ZoneItemsProperty =
            DependencyProperty.Register(ZoneItemsPropertyName, typeof(List<ZoneItem>),
            typeof(ProfileChartSeries), new PropertyMetadata(null, (sender, e) =>
            {
                var series = (ProfileChartSeries)sender;
                series.RaisePropertyChanged(YAxisPropertyName, e.OldValue, e.NewValue);
            }));
        public List<ZoneItem> ZoneItems
        {
            get {return this.GetValue(ZoneItemsProperty) as List<ZoneItem>; }
            set {this.SetValue(ZoneItemsProperty, value);}
        }
        #endregion  //ZoneItems

        #region Property - TemperatureData
        public const string TemperatureDataPropertyName = "TemperatureData";
        public static readonly DependencyProperty TemperatureDataProperty =
            DependencyProperty.Register(TemperatureDataPropertyName, typeof(List<DataItem>),
            typeof(ProfileChartSeries), new PropertyMetadata(null, (sender, e) =>
            {
                var series = (ProfileChartSeries)sender;
                series.RaisePropertyChanged(YAxisPropertyName, e.OldValue, e.NewValue);
            }));
        public List<DataItem> TemperatureData
        {
            get { return this.GetValue(TemperatureDataProperty) as List<DataItem>; }
            set { this.SetValue(TemperatureDataProperty, value); }
        }
        #endregion  //ZoneItems

The classes for the ZoneItem and DataItem are below:

    public class ZoneItem
    {
        public int Number { get; set; }
        public string Name { get; set; }
        public double Length { get; set; }
        public string LengthUnit { get; set; }
        public double LengthInSpeedUnit { get; set; }
        public double LengthInSystemUnit { get; set; }
        public bool IsHeatingZone { get; set; }
        public double SetTemp { get; set; }
    }
    
    public class DataItem
    {
        public double temperature { get; set; }
        public double time { get; set; }
    }

Using the "TemperatureData" object as the ItemSource in the markup works fine, but when I try to bind it to a custom property the property is always null in the code behind. Same for the ZoneItems property.

I suspect there is something simple that I'm missing here, but I can't figure out what it is.

Thanks in advance for any help anyone might have on this.

-Aaron

Parents
No Data
Reply Children
No Data