Monitor a change in the property of a Telerik ScheduleView control in WPF

user1017882 picture user1017882 · Feb 29, 2012 · Viewed 23.8k times · Source

I have 2 properties to a class (WPF control): HorizontalOffset and VerticalOffset (both public Double's). I would like to call a method whenever these properties change. How can I do this? I know of one way - but I'm pretty sure it's not the right way (using a DispatcherTimer of very short tick intervals to monitor the property).

EDIT FOR MORE CONTEXT:

These properties belong to a telerik scheduleview control.

Answer

Andras Zoltan picture Andras Zoltan · Feb 29, 2012

Leverage the INotifyPropertyChanged interface implementation of the control.

If the control is called myScheduleView:

//subscribe to the event (usually added via the designer, in fairness)
myScheduleView.PropertyChanged += new PropertyChangedEventHandler(
  myScheduleView_PropertyChanged);

private void myScheduleView_PropertyChanged(Object sender,
  PropertyChangedEventArgs e)
{
  if(e.PropertyName == "HorizontalOffset" ||
     e.PropertyName == "VerticalOffset")
  {
    //TODO: something
  }
}