我现在在代码中把数据半丁到控件上面如下:
this.rotateAngle.SetBinding(TextBlock.TextProperty, new Binding("ShortTag") { Source = GlobalData.Instance.da["callAngle"], Mode = BindingMode.OneWay, Converter = new CallAngleConverter() });
如果GlobalData.Instance.da["callAngle"]中的值变化了,控件的值也会跟着改变。
有没有什么办法,我加一个条件,比如说:
bool update = true;
if(update)
{
this.rotateAngle的绑定值更新;
}
else
{
this.rotateAngle的绑定值不更新;
}
可以定义一个类:
class CacheData<T> where T : ICloneable
{
public bool Locked { get;set;}
private T _cached;
private T _target;
public T value
{
get { if (!Locked) _cached = target.Clone(); return _cached; }
set { _cached = _target = value.Clone(); }
}
}
绑定这个类