监视WPF中Telerik ScheduleView控件的属性更改 [英] Monitor a change in the property of a Telerik ScheduleView control in WPF
本文介绍了监视WPF中Telerik ScheduleView控件的属性更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对一个类(WPF控件)有2个属性: HorizontalOffset
和 VerticalOffset
(都是公共 Double
的).每当这些属性更改时,我都想调用一个方法.我怎样才能做到这一点?我知道一种方法-但是我很确定这不是正确的方法(使用间隔时间非常短的 DispatcherTimer
来监视属性).
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).
编辑更多上下文:
这些属性属于telerik scheduleview控件.
These properties belong to a telerik scheduleview control.
推荐答案
利用控件的 INotifyPropertyChanged
接口实现.
如果控件名为 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
}
}
这篇关于监视WPF中Telerik ScheduleView控件的属性更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文