WPF 数组绑定界面元素的问题
请教,WPF中如何使用数组绑定界面元素(多个Text)?
现状:
1、在界面中进行了绑定
<TextBox Margin="0,386,694,0" Name="AValveText1" Text="{Binding Path=ValAO[1]}" Style="{StaticResource TextBlockAValve}" Width="33" IsReadOnly="True" TextChanged="AValveText_TextChanged" />
2、绑定用的变量单独建了一个类
class WpfVarDr:INotifyPropertyChanged
{
private int[] valAO = new int[10] { 20, 30, 0, 0, 0, 0, 0, 0, 0, 0 };
public int[] ValAO
{
set
{
valAO = value;
NotifyPropertyChanged("valAO");
}
get { return valAO; }
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (propertyName != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
3、问题:实时改变变量时,界面(text)不能做出响应。