ListViewItem DataTemplate not updating when DataContext changed


  • I'm trying to update a property in my ListViewItem's DataContext when a button within the ListViewItem is clicked.

    private async void ListViewItemButton_Click(object sender, ItemClickEventArgs e) {    
    Button btn = sender as Button;    
    (btn.DataContext as ItemViewModel).Name = "Name Changed";

    This changes the desired property correctly, and upon clicking the button again I have checked that the property is being changed to the new value.

    However the DataBinding isn't being updated in the DataTemplate for the ListViewItem when I change the property to display the new value.

    Do I need to call a method on the ListViewItem to force it to reload its DataBinding values?

    Thursday, May 8, 2014 3:24 PM

All replies

  • Does the Name property fire a PropertyChanged event when it is set? The binding depends on that to know that the value has updated.

    Thursday, May 8, 2014 11:01 PM