I want to update a Column in a listview when the checkbox is checked in the same row. Checkbox is a part of a row.
View:
Check Box:
<CheckBox Tag="{Binding ID}" Checked="chbAccount_checked" Unchecked="chbAccount_Unchecked"/>
Text block in the column that needed to be updated:
<TextBlock Text="{Binding MyColumnValue }" />
Code Behind:
private void chbAccount_checked(object sender, RoutedEventArgs e)
{
CheckBox chb = sender as CheckBox;
int Id= Convert.ToInt16(chb.Tag);
ViewModel.UpdateColumnValue(Id);
myListView.ItemsSource = ViewModel.Accounts;
this.myListView.UpdateLayout();
}
ViewModel:
public void UpdateColumnValue(int Id)
{
foreach(var a in Accounts)
{
if(a.ID == Id)
{
a.MyColumnValue = "Yes";
}
}
}
Account list is updating but the list view doesn't show the Modified values in the column. I have tried refreshing listview by listview.item.refresh(). Didn't work.
Please help. Thank you!
Aucun commentaire:
Enregistrer un commentaire