Согласно вашему описанию, вы хотите обновить данные ListView при нажатии кнопки в строке ListView. Я делаю один пример, который вы можете посмотреть:
<StackLayout>
<ListView x:Name="listview1" ItemsSource="{Binding models}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<Label Text="{Binding name}" />
<Label
x:Name="label1"
Grid.Column="1"
Text="{Binding quality}" />
<Button
Grid.Column="2"
Command="{Binding BindingContext.command, Source={x:Reference listview1}}"
CommandParameter="{Binding Id}"
Text="increment" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
public partial class Page24 : ContentPage
{
public ObservableCollection<model31> models { get; set; }
public RelayCommand1 command { get; set; }
public Page24 ()
{
InitializeComponent ();
models = new ObservableCollection<model31>()
{
new model31(){Id=1, name="cherry",quality=12},
new model31(){Id=2,name="barry",quality=31},
new model31(){Id=3,name="Wendy",quality=25},
new model31(){Id=4,name="Amy",quality=32}
};
command = new RelayCommand1(obj=>method1((int)obj));
this.BindingContext = this;
}
public void method1(int Id)
{
IEnumerable<model31> list = models.Where(x => x.Id == Id);
foreach(model31 m in list)
{
m.quality = m.quality + 1;
}
}
}
Класс RelayCommand1 , для реализации команды:
public class RelayCommand1 : ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute;
public RelayCommand1(Action<object> execute)
: this(execute, null)
{
}
public RelayCommand1(Action<object> execute, Predicate<object> canExecute)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_execute(parameter);
}
}
Класс ViewModelBase , для реализации уведомления.
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
![enter image description here](https://i.stack.imgur.com/F1U4t.gif)