AndreiMisiukevich / CardView

CardsView | CarouselView | CoverflowView | CubeView for Xamarin.Forms
MIT License
710 stars 114 forks source link

Is it possible to add an clicked/selected event? #365

Closed p0dgana closed 3 years ago

p0dgana commented 3 years ago

Is it possible to make it so user can click on the card? I want to make it so it will open a different page...

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:cards="clr-namespace:PanCardView;assembly=PanCardView" xmlns:controls="clr-namespace:PanCardView.Controls;assembly=PanCardView"
             x:Class="projekt.Teme">
    <ContentPage.Content>
        <cards:CoverFlowView x:Name="cardView" SelectedIndex="{Binding t_id, Mode=TwoWay}">
            <cards:CoverFlowView.ItemTemplate IsPullToRefreshEnabled="true">
                <DataTemplate>
                    <Frame VerticalOptions="Center"
                    HorizontalOptions="Center"
                    HeightRequest="300"
                    WidthRequest="300"
                    Padding="0" 
                    HasShadow="True"
                    IsClippedToBounds="true"
                    CornerRadius="10"
                    BackgroundColor="White">
                        <StackLayout>
                            <Image Aspect="AspectFit" Source="{Binding t_slika}"></Image>
                                <Label Text="{Binding t_ime}" FontSize="Medium" FontAttributes="Bold"/>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Grid.Row="0" Width="Auto"/>
                                    <ColumnDefinition Grid.Row="0" Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Frame Padding="5" Grid.Row="0" Grid.Column="0" BackgroundColor="#d9534f" CornerRadius="5" HorizontalOptions="End" VerticalOptions="StartAndExpand">
                                    <Label>
                                        <Label.FormattedText>
                                            <FormattedString>
                                                <FormattedString.Spans>
                                                    <Span Text="{Binding st_prijav}" />
                                                    <Span Text="/"></Span>
                                                    <Span Text="{Binding st_omejitev}"></Span>
                                                </FormattedString.Spans>
                                            </FormattedString>
                                        </Label.FormattedText>
                                    </Label>
                                </Frame>
                                <Frame Padding="5" Grid.Row="0" Grid.Column="1" BackgroundColor="#5bc0de" CornerRadius="5" HorizontalOptions="End" VerticalOptions="StartAndExpand">
                                    <Label>
                                        <Label.FormattedText>
                                            <FormattedString>
                                                <FormattedString.Spans>
                                                    <Span Text="{Binding p_ime}" />
                                                </FormattedString.Spans>
                                            </FormattedString>
                                        </Label.FormattedText>
                                    </Label>
                                </Frame>
                            </Grid>
                        </StackLayout>
                    </Frame>
                </DataTemplate>
            </cards:CoverFlowView.ItemTemplate>
        </cards:CoverFlowView>
    </ContentPage.Content>
</ContentPage>
AndreiMisiukevich commented 3 years ago

Hello, just add TapGestureRecognizer to Frame :)