Issue
i want to delete or update rows of a list view by the primary key which is Label
<Label Grid.Column="1"
Grid.Row="0"
Text="{Binding Label}"
FontSize="20"
TextColor="Black"
Margin="0,10"
FontFamily="Comfortaa-Light"/>
<Label Grid.Column="2"
Grid.Row="1"
Text="{Binding Todo}"
FontSize="20"
TextColor="Black"
Margin="0,10,0,0"
FontFamily="Comfortaa-Light"
HorizontalOptions="Start"
VerticalOptions="Center"/>
<ImageButton Grid.Column="2"
Grid.Row="0"
HorizontalOptions="End"
VerticalOptions="End"
Source="plus.png"
Margin="9"
BackgroundColor="Transparent"
Clicked="AddReminder"
here parameter{{Binding Label}} />
I need help and thank you
Solution
Since you had used Data-binding(MVVM) .It would better to handle the logic by using Command . In addition, we could pass the text of label(or the whole model) instead of the Label itself .
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App11.MainPage"
x:Name="page"> // set the name of the page
<ImageButton Grid.Column="2"
Grid.Row="0"
HorizontalOptions="End"
VerticalOptions="End"
Source="plus.png"
Margin="9"
BackgroundColor="Transparent"
Command="{Binding Source={x:Reference page},Path=BindingContext.xxxCommand}}"
CommandParameter="{Binding .}"
/>
in your viewmodel
public ICommand xxxCommand { get; set; }
xxxCommand = new Command((arg)=> {
//var model = arg as YourModel;
// you can get the text of label from the model and do something you want
});
Answered By - Lucas Zhang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.