I'm using the code from the answer here WPF: how to bind lines to UI elements? And I'm getting "Value produced by BindingExpression is not valid for target property.; Value='NaN'". The only difference between my code and in the link is that I don't set Point point = null;
just Point point;
because it produces a convertion problem.
The MidpointConcerter.cs is exactyl the same as in the link. My method to bind:
private void BindLineToScatterViewItems(Line line, ScatterViewItem StartItem, ScatterViewItem EndItem)
{
var x = new MidpointConverter(false);
var y = new MidpointConverter(true);
BindingOperations.SetBinding(line, Line.X1Property,
new Binding { Source = StartItem, Converter = x, ConverterParameter = MidpointSide.Bottom });
BindingOperations.SetBinding(line, Line.Y1Property,
new Binding { Source = StartItem, Converter = y, ConverterParameter = MidpointSide.Bottom });
//old in the middle
BindingOperations.SetBinding(line, Line.X2Property,
new Binding { Source = EndItem, Path = new PropertyPath("ActualCenter.X") });
BindingOperations.SetBinding(line, Line.Y2Property,
new Binding { Source = EndItem, Path = new PropertyPath("ActualCenter.Y") });
}
Can someone help me and say whats wrong and how I can fix it?