Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更新/刷新绑定到wpf/xaml中另一个元素属性的TextBlock_C#_Wpf_Xaml_Listview_Textblock - Fatal编程技术网

C# 更新/刷新绑定到wpf/xaml中另一个元素属性的TextBlock

C# 更新/刷新绑定到wpf/xaml中另一个元素属性的TextBlock,c#,wpf,xaml,listview,textblock,C#,Wpf,Xaml,Listview,Textblock,我想更新绑定到listview项属性的textblock中的文本。这是我将textblock绑定到listview项的方式 mWindow.xaml <ListView Name="ListViewDetails" ItemsSource="{Binding Persons}" SelectedItem="{Binding CurrentPerson}"> ... </ListView> <Te

我想更新绑定到listview项属性的textblock中的文本。这是我将textblock绑定到listview项的方式

mWindow.xaml

<ListView Name="ListViewDetails"               
      ItemsSource="{Binding Persons}" 
      SelectedItem="{Binding CurrentPerson}">
      ...
</ListView> 

<TextBlock>
     <Run Text="{Binding ElementName=ListViewDetails, Path=SelectedItem.Office}"/>
     ...
</TextBlock>

我认为我必须为CurrentPerson属性实现INotifyPropertyChanged。当我为person类实现INotifyPropertyChanged时,它起作用。

绑定的项是否实现INotifyPropertyChanged?如果绑定未中断,请检查输出窗口@查理:是的,我知道,但我不知道我的解决方案是否正确。
public partial class mWindow: Window , INotifyPropertyChanged 
{

            private Person currentPerson;
            public Person CurrentPerson
            {
                get
                {
                    return currentPerson;
                }
                set
                {
                    this.currentPerson = value;
                    this.NotifyPropertyChanged("CurrentPerson"); 
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;
            private void NotifyPropertyChanged(string propertyName)
            {
                var handler = this.PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }

            }

            private void editLisView{

            ...

            // refresh ListView
            ICollectionView view =CollectionViewSource.GetDefaultView(ListViewInsuranceDetails.ItemsSource);
            view.Refresh();
            }

}