我正在使用datagrid的第三方控件。我在模型类中实现了属性更改事件,当我使用
时它正在工作 Text="{Binding itemQty, UpdateSourceTrigger=propertychanged}"
它甚至在我的数据源中更新,但是我有另一个文本框,这里数据不是从项目源检索,尽管项目源是用新值更新的。 我想显示第一个文本框的属性更改事件的数据,行是动态的,所以我不能直接调用它们。 如果我刷新它正在显示的数据源,但我不能使用该过程,因为当项目很多时,它是时间进行处理。
答案 0 :(得分:1)
我想显示第一个文本框属性更改事件的数据,行是动态的
问题是您没有为Mode=TwoWay
媒体资源设置Text
。 UpdateSourceTrigger
定义了一些常量,指示绑定源何时由双向绑定中的绑定目标更新。
<TextBox Text="{Binding Info,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Text="{Binding Info}"/>
代码
private string info { get; set; }
public string Info
{
get { return info; }
set
{
info = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string properName = null)
{
if(PropertyChanged != null)
this.PropertyChanged(this,new PropertyChangedEventArgs(properName));
}