0

I'm creating an object that will be applied to a chart and I'm wanting to bind a property to a property in that object.

Here is the property I need to bind (TimeSpanRange) and the property in the object I need to bind it to (VisibleRange):

    private TimeSpanRange _timeSpanRange = new TimeSpanRange(new TimeSpan(0), new TimeSpan(1, 30, 0));

    public TimeSpanRange TimeSpanRange
    {
        get { return _timeSpanRange; }
        set
        {
            _timeSpanRange = value;
            OnPropertyChanged();
        }
    }

    XAxes.Add(new TimeSpanAxisViewModel()
        {
            AxisTitle = "Time",
            VisibleRange = TimeSpanRange // TODO: Bind this property
        });
n0kx
  • 61
  • 7
  • https://stackoverflow.com/questions/7525185/how-to-set-a-binding-in-code – J.H. Jan 07 '19 at 19:20
  • 1
    You can only use WPF's binding mechanism where the target of the binding is a DependencyProperty. If you want to have some update mechanism between "normal" properties of two different objects, let one object (or both objects, depending if you want updates in both directions) subscribe to the PropertyChangedEvent of the other object and handle the event appropriately... –  Jan 07 '19 at 19:36

0 Answers0