0
如果您使用UpdateSourceTrigger.PropertyChanged綁定文本框,每次更新您的數據源時,TextBox上的textproperty發生更改,並且您有RaisedPropertyChanged該屬性,那麼你的文本框變得非常慢(在鍵入一些文本時),如果你有很多文本里面(超過1000個字符)。有人爲此問題提供解決方案嗎?我需要通知GUI關於數據模型的改變。我使用MVVM模式。我已經嘗試將我的內容屬性轉換爲依賴對象 - >相同的文本框輸入lag。這個問題困擾我,因爲這應該是基本的silverlight東西?TextBox DataBinding上的UpdateSourceTrigger.PropertyChanged和INotifyChanged在TextBox中鍵入的Silverlight 5極其緩慢
歡呼 托比亞斯
var binding = new Binding("Content");
binding.Mode = BindingMode.TwoWay;
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
myTextBox.SetBinding(TextBox.TextProperty, binding);
private string m_content;
public string Content
{
get { return m_content; }
set
{
m_content = value;
//RaisePropertyChanged("Content");
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="propertyName">The property that has a new value.</param>
protected void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}