protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == BGColorProperty.PropertyName) { BackgroundColor = BGColor; } else if (propertyName == IconSrcProperty.PropertyName) { Icon.Source = IconSrc; } else if (propertyName == OnClickCommandProperty.PropertyName || propertyName == ExtraCommandProperty.PropertyName) { onTap.Command = new Command(() => { OnClickCommand.Execute(null); if (ExtraCommand != null) { ExtraCommand.Execute(null); } }); if (!GestureRecognizers.Contains(onTap)) { GestureRecognizers.Add(onTap); } } }
private void UpdateInteraction() { if (_textElement == null) { return; } if (SearchMode == SearchModes.None || IsFullScreen()) { _textElement.IsVisible = false; _textElement.InputTransparent = true; _textElement.IsEnabled = false; if (_tapGesture == null) { _tapGesture = new TapGestureRecognizer(); _tapGesture.Tapped += OnTapped; } if (GestureRecognizers.Contains(_tapGesture) == false) { GestureRecognizers.Add(_tapGesture); } } else { bool isActive = IsFullScreen() == false; if (isActive) { _textElement.IsVisible = true; _textElement.InputTransparent = false; _textElement.IsEnabled = true; } else { _textElement.IsVisible = false; _textElement.InputTransparent = true; _textElement.IsEnabled = false; } if (_tapGesture != null && GestureRecognizers.Contains(_tapGesture)) { GestureRecognizers.Remove(_tapGesture); } } }
private void SvgImage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // Fix a known issue in ListView where ItemTapped event doesn't get fired if the list view item template has a tap gesture while it also uses // ContextActions like long press action to show some menu items, in this case when we add the SvgImage inside list view item template the list // view item will NOT receive the ItemTapped event and so the item will not be clickable, this workaround will fix it by checking for the // SvgImage.IsEnabled property, you need to set it to FALSE when you use the SvgImage inside list view item template. if (e.PropertyName.Equals(IsEnabledProperty.PropertyName)) { if (IsEnabled) { if (!GestureRecognizers.Contains(_tapGestureRecognizer)) { GestureRecognizers.Add(_tapGestureRecognizer); } } else { GestureRecognizers.Remove(_tapGestureRecognizer); } } }