Je voudrais mettre à jour le texte dans le bloc de texte qui est lié à la propriété de l'élément listview. C'est ainsi que je lie le bloc de texte à l'élément listview.Mise à jour/Actualiser TextBlock qui est lié à une autre propriété d'élément dans wpf/xaml
mWindow.xaml
<ListView Name="ListViewDetails"
ItemsSource="{Binding Persons}"
SelectedItem="{Binding CurrentPerson}">
...
</ListView>
<TextBlock>
<Run Text="{Binding ElementName=ListViewDetails, Path=SelectedItem.Office}"/>
...
</TextBlock>
Si la propriété de l'élément dans listview est modifié, le texte est mis à jour pas.
mWindow.xaml.cs
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();
}
}
L'élément lié implémente-t-il INotifyPropertyChanged? – Charleh
Vérifiez votre fenêtre de sortie si la liaison ne se casse pas !! –
@Charleh Oui je l'ai fait, mais je ne sais pas, si ma solution est correcte. – Matt