RangeSeries LowBinding ValueConverter

2 posts, 0 answers
  1. Philipp
    Philipp avatar
    1 posts
    Member since:
    Jun 2020

    Posted 06 Jul 2020 Link to this post

    Hi there,

    I'm trying to display a range series that is defined by a collection and a gap.

    The ObservableCollection is defining the upper limit. The lower limit is defined by the upper limit minus the gap.

    For this display I want to use a value converter that returns the lower limit for each upper limit.

            <telerik:CategoricalAxis />
            <telerik:RangeSeries ItemsSource="{Binding Path=SensorParameter.Range_UpperLimit}" HighBinding="Range_UpperLimit" CategoryBinding="RPM">
                    <MultiBinding Converter="{StaticResource ConvertOKLowValue}">
                        <Binding Path="Range_UpperLimit" />
                        <Binding Path="Range_Gap" />


    The SensorParameter struct looks like this:

    01.public class RPM_Range : ObservableObject
    03.    public float Range_Gap { get; set; }
    04.    public ObservableCollection<Range_Limit> Range_UpperLimit { get; set; }
    07.public class Range_Limit: ObservableObject
    09.    public float RPM
    10.    {
    11.        get; set;
    12.    }
    14.    public float OK_Range_UpperLimit
    15.    {
    16.        get; set;
    17.    }


    The value converter is implemented like this:

    01.public class RangeSeriesLowConverter : IMultiValueConverter
    03.    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    04.    {
    05.        double? _RangeUpperLimit = values[0] as double?;
    06.        double? _RangeGap = values[1] as double?;
    07.        if (_RangeUpperLimit - _RangeGap < 0)
    08.            return 0;
    09.       return _RangeUpperLimit - _RangeGap;
    10.    }
    12.    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    13.    {
    14.        throw new NotImplementedException();
    15.    }


    UpperLimit binds correctly. But I'm not getting the binding to the lower limit correctly. While debugging the value converter is called, but the arguments are not passed correctly.

    Is there a restriction using value converters for the low binding?


    Thanks in advance for your help.



  2. Martin Ivanov
    Martin Ivanov avatar
    2580 posts

    Posted 09 Jul 2020 Link to this post

    Hello Philipp,

    The binding properties like LowBinding, HighBinding, ValueBinding, etc., are expecting a DataPointBinding object. When the property is set in XAML it expects a string representing the name of the property that will be used for the corresponding binding. This is the the current code doesn't work.

    To acheive your requirement you can use a GenericDataPointBinding for the LowBinding property. You can use the ValueSelector function of the generic binding to get the value that is currently calculated in your converter. The Create Data-Bound Chart article shows how to use the GenericDataPointBinding. 

    Martin Ivanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top