Monitor a change in the property of a Telerik ScheduleView control in WPF
I know of one way ...
DispatcherTimer
Wow avoid that :) INotifyPropertyChange
interface is your friend. See the msdn for samples.
You basically fire an event(usually called onPropertyChanged
) on the Setter
of your properties and the subscribers handle it.
an example implementation from the msdn
goes:
// This is a simple customer class that
// implements the IPropertyChange interface.
public class DemoCustomer : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
public string CustomerName
{
//getter
set
{
if (value != this.customerNameValue)
{
this.customerNameValue = value;
NotifyPropertyChanged("CustomerName");
}
}
}
}
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
}
}