BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<Grid VerticalOptions="Center">
<card:SfCardLayout BindableLayout.ItemsSource="{Binding Data}" CardTappedCommand="{Binding CardTappedCommand}" CardTappedCommandParameter="{x:Reference cardLayout}" x:Name="cardLayout" BackgroundColor="#F0F0F0" SwipeDirection="Left" HeightRequest="500"> <BindableLayout.ItemTemplate> <DataTemplate> <card:SfCardView> ………….
………….
</card:SfCardView> </DataTemplate> </BindableLayout.ItemTemplate> </card:SfCardLayout> </Grid> |
public class ViewModel: INotifyPropertyChanged
{
public ObservableCollection<Model> Data { get; set; } public event PropertyChangedEventHandler PropertyChanged; public ICommand CardTappedCommand { get; set; } private object cardDescription; public object CardDescription { get { return cardDescription; } set { cardDescription = value; RaisePropertyChanged("CardDescription"); } } void RaisePropertyChanged(string name) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(name)); } } public ViewModel()
{ CardTappedCommand = new Command<object>(CardTappedEvent);
}
private void CardTappedEvent(object args)
{ SfCardLayout cardLayout = args as SfCardLayout; CardDescription = (cardLayout.BindingContext as ViewModel).Data[cardLayout.VisibleCardIndex].Price; } } |
Hi
Mohammed,
Query
1: Can we pass the parameters using
x:name.
Yes,
you can pass any object as a parameter of CardTappedCommandParameter property
using x:Name attribute.
Query
2: Can you check using the code given,
whether the card tapped command parameters pass the card layout.
Yes, we
have checked the argument in the CardTappedCommand event using the provided
code snippet and it is working fine in our sample.
Query
3: Provide solution for getting tapped
in card tapped command.
We have
achieved your requirement in another way. Please refer the below code snippet.
Solution: Get the tapped card view details as a
parameter without setting CardTappedCommandParameter
As we
have mentioned earlier, you no need to set CardTappedCommandParameter property
explicitly, because we have passed the particular tapped card view as a
parameter by default. Please refer the below code snippet for your reference.
Code
Snippet:
Xaml:
<card:SfCardLayout BindableLayout.ItemsSource="{Binding Data}" ……… </BindableLayout.ItemTemplate> |
C#:
private void CardTappedEvent(object args) |
Could
you please confirm us whether you may fulfil your requirement using the above
provided solution?
Regards,
Lakshmi
R.