相关疑难解决方法(0)

如何使用INotifyPropertyChanged更新数组绑定?

假设我有一节课:

class Foo
{
  public string Bar
  {
    get { ... }
  }

  public string this[int index]
  {
    get { ... }
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以使用"{Binding Path = Bar}"和"{Binding Path = [x]}"绑定到这两个属性.精细.

现在让我们说我想实现INotifyPropertyChanged:

class Foo : INotifyPropertyChanged
{
  public string Bar
  {
    get { ... }
    set
    {
      ...

      if( PropertyChanged != null )
      {
        PropertyChanged( this, new PropertyChangedEventArgs( "Bar" ) );
      }
    }
  }

  public string this[int index]
  {
    get { ... }
    set
    {
      ...

      if( PropertyChanged != null …
Run Code Online (Sandbox Code Playgroud)

wpf

14
推荐指数
3
解决办法
6876
查看次数

标签 统计

wpf ×1