-
Notifications
You must be signed in to change notification settings - Fork 251
Description
Hi,
I have a button in one page which works using markup with either these lines of code
- .Bind(Button.CommandProperty, nameof(DeliveryCollectionDetailsPageViewModel.CompleteOrderCommand))
- .BindCommand(static (DeliveryCollectionDetailsPageViewModel vm) => vm.CompleteOrderCommand, mode: BindingMode.OneWay)
I have another page with a CollectionView who's template I define in another file under Views which contains a button.
The above 2 lines don't work in the DataTemplate and neither di the following.
- .Invoke(cv => {
var tapGesture = new TapGestureRecognizer();
tapGesture.SetBinding(TapGestureRecognizer.CommandProperty, "TakeRightPictureForConsignmentCommand");
cv.GestureRecognizers.Add(tapGesture);
})
4).BindTapGesture( (ConsignmentPicturesViewModel vm) => vm.TakeRightPictureForConsignmentCommand)
5).Bind(Button.CommandProperty, getter: new Binding("TakeRightPictureForConsignmentCommand", source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor, typeof(ConsignmentPicturesViewModel))))
6).Bind<Button, ConsignmentPicturesViewModel, ICommand>(
Button.CommandProperty,getter: (ConsignmentPicturesViewModel vm)=>vm.TakeRightPictureForConsignmentCommand,
new Binding("TakeRightPictureForConsignmentCommand",
source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor,
typeof(DeliveryCollectionDetailsPageViewModel)))
- .Bind<Button, ConsignmentPicturesViewModel, ICommand>(
Button.CommandProperty,getter: nameof(ConsignmentPicturesViewModel.TakeRightPictureForConsignmentCommand)),
new Binding("TakeRightPictureForConsignmentCommand",
source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor,
typeof(DeliveryCollectionDetailsPageViewModel)))
Before I give up and re-write the page in Xaml, do you have any suggestions?
Thanks! π