Sök…


Tryck på Gest

Med Tap Gesture kan du göra ett klickbart UI-element (bilder, knappar, StackLayouts, ...):

(1) I kod med händelsen:

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
    // handle the tap
};
image.GestureRecognizers.Add(tapGestureRecognizer);

(2) I kod med ICommand (till exempel med MVVM-mönster ):

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.SetBinding (TapGestureRecognizer.CommandProperty, "TapCommand");
image.GestureRecognizers.Add(tapGestureRecognizer);

(3) Eller i Xaml (med händelse och ICommand bara en):

<Image Source="tapped.jpg">
    <Image.GestureRecognizers>
        <TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped" Command="{Binding TapCommand"} />
  </Image.GestureRecognizers>
</Image>


Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow