This question is locked. New answers and comments are not allowed.
In my application I am dealing a lot with objects that have a concept of a range, for that reason I abstracted the logic related to ranges into a separate class. Below is the skeleton of the class, though in my application this class does much more (ex. checks for overlapping, containment, equality, uniqueness, etc).
My business logic classes include this Range class and rely on this class to perform range related operations, for example:
I would like to chart my business objects using RangeBarSeries, and my expectation was that I could bind HighBinding and LowBinding properties of the RangeBarSeries to the corresponding High and Low properties of my Range class (see below) embedded in my business logic classes.
Note: DataPointsCollection in the example below, is of type ObservableCollection<HeartRateZones>, where HeartRateZone contains Range class.
Unfortunately, I am getting this exception:
{System.ArgumentException: Could not find property 'Range.High' for type 'ZonesVisualization.Controls.HeartRateZone'
at Telerik.Windows.DynamicHelper.CreatePropertyValueGetter(Type type, String propertyName)
at Telerik.Windows.Controls.PropertyNameDataPointBinding.GetValue(Object instance)
at Telerik.Windows.Controls.RangeSeriesBaseDataSource.InitializeBinding(DataPointBindingEntry binding)
at Telerik.Windows.Controls.ChartSeriesDataSource.GenerateDataPoint(Object dataItem, Int32 index)
at Telerik.Windows.Controls.ChartSeriesDataSource.BindCore()
at Telerik.Windows.Controls.ChartSeriesDataSource.Bind()
at Telerik.Windows.Controls.ChartSeriesDataSource.Rebind(Boolean itemsSourceChanged, IEnumerable newSource)
at Telerik.Windows.Controls.ChartSeriesDataSource.set_ItemsSource(IEnumerable value)
at Telerik.Windows.Controls.ChartSeries.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.Dependen
Attaching a project that reproduces this issue (renamed zip to jpg).
Thanks.
Alex.
public
class
Range : INotifyPropertyChanged
{
private
int
high;
private
int
low;
public
Range(
int
low,
int
high)
{
this
.low = Low;
this
.high = High;
}
public
event
PropertyChangedEventHandler PropertyChanged;
public
int
High
{
get
{
return
this
.high;
}
set
{
this
.high = value;
this
.OnPropertyChanged();
}
}
public
int
Low
{
get
{
return
this
.low;
}
set
{
this
.low = value;
this
.OnPropertyChanged();
}
}
[NotifyPropertyChangedInvocator]
protected
virtual
void
OnPropertyChanged([CallerMemberName]
string
propertyName =
null
)
{
var handler = PropertyChanged;
if
(handler !=
null
)
{
handler(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
}
}
My business logic classes include this Range class and rely on this class to perform range related operations, for example:
public
class
HeartRateZone : INotifyPropertyChanged
{
private
string
name;
private
bool
isSelected;
private
Range range;
public
HeartRateZone(
string
name, Range range)
{
this
.Range = range;
Name = name;
}
public
event
PropertyChangedEventHandler PropertyChanged;
public
string
Name
{
get
{
return
this
.name;
}
set
{
this
.name = value;
this
.OnPropertyChanged();
}
}
public
bool
IsSelected
{
get
{
return
this
.isSelected;
}
set
{
this
.isSelected = value;
this
.OnPropertyChanged();
}
}
public
Range Range
{
get
{
return
this
.range;
}
set
{
this
.range = value;
this
.OnPropertyChanged();
}
}
[NotifyPropertyChangedInvocator]
private
void
OnPropertyChanged([CallerMemberName]
string
propertyName =
null
)
{
var handler = PropertyChanged;
if
(handler !=
null
)
{
handler(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
}
}
I would like to chart my business objects using RangeBarSeries, and my expectation was that I could bind HighBinding and LowBinding properties of the RangeBarSeries to the corresponding High and Low properties of my Range class (see below) embedded in my business logic classes.
Note: DataPointsCollection in the example below, is of type ObservableCollection<HeartRateZones>, where HeartRateZone contains Range class.
<
telerikChart:RangeBarSeries
x:Name
=
"BarSeries"
CategoryBinding
=
"Name"
ItemsSource
=
"{Binding ElementName=HeartRateZoneChartControl, Path=DataPointsCollection}"
Canvas.ZIndex
=
"2"
HighBinding
=
"Range.High"
LowBinding
=
"Range.Low"
>
Unfortunately, I am getting this exception:
{System.ArgumentException: Could not find property 'Range.High' for type 'ZonesVisualization.Controls.HeartRateZone'
at Telerik.Windows.DynamicHelper.CreatePropertyValueGetter(Type type, String propertyName)
at Telerik.Windows.Controls.PropertyNameDataPointBinding.GetValue(Object instance)
at Telerik.Windows.Controls.RangeSeriesBaseDataSource.InitializeBinding(DataPointBindingEntry binding)
at Telerik.Windows.Controls.ChartSeriesDataSource.GenerateDataPoint(Object dataItem, Int32 index)
at Telerik.Windows.Controls.ChartSeriesDataSource.BindCore()
at Telerik.Windows.Controls.ChartSeriesDataSource.Bind()
at Telerik.Windows.Controls.ChartSeriesDataSource.Rebind(Boolean itemsSourceChanged, IEnumerable newSource)
at Telerik.Windows.Controls.ChartSeriesDataSource.set_ItemsSource(IEnumerable value)
at Telerik.Windows.Controls.ChartSeries.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.Dependen
Attaching a project that reproduces this issue (renamed zip to jpg).
Thanks.
Alex.