简体   繁体   中英

No button Clicking Event in xamarin form inside a DataTemplate

I am using swipecards in my xamarin form project.

This is my Xaml code--

<swipecards:CardStackView Grid.Row="0" x:Name="CardStackView" ItemsSource="{Binding Cards[0]}"    Swiped="CardStackView_Swiped" StartedDragging="CardStackView_dragged"  Margin="20" BackgroundColor="#E0E0E0">
                <swipecards:CardStackView.ItemTemplate>
                    <DataTemplate>
                        <StackLayout Padding="0,2,0,2" x:Name="layout">

                            <StackLayout Orientation="Horizontal" VerticalOptions="Start">
                                <Label Text="{Binding .FullJobName}" HorizontalOptions="Start" Style="{DynamicResource TitleStyle}" />
                                <Grid>
                                    <Image x:Name="MyImage" Source="{Binding .CompanyProfImg}" HorizontalOptions="End" HeightRequest="50" WidthRequest="50" />
                                    <ActivityIndicator BindingContext="{x:Reference MyImage}" IsRunning="{Binding IsLoading}}"/>
                                </Grid>

                            </StackLayout>

                            <StackLayout HorizontalOptions="StartAndExpand">
                                <Label Text="{Binding .LocationName}" HorizontalOptions="StartAndExpand" Style="{DynamicResource SubtitleTextStyle}" />
                                <Label Text="{Binding .TotalSalary }" Style="{DynamicResource SubtitleTextStyle}" />
                            </StackLayout>

                            <StackLayout>
                                <Label Text="Comapny Name" Style="{DynamicResource TitleStyle}" HorizontalOptions="StartAndExpand"/>
                                <Label Text="{Binding .CompanyName}" Style="{DynamicResource ListItemTextStyle}" HorizontalOptions="StartAndExpand"/>
                            </StackLayout>

                            <StackLayout>
                                <Label Text="Key Skills" Style="{DynamicResource TitleStyle}" HorizontalOptions="StartAndExpand"/>
                                <Label Text="{Binding .Skills}" Style="{DynamicResource ListItemTextStyle}" HorizontalOptions="StartAndExpand"/>
                            </StackLayout>

                            <StackLayout>
                                <Label Text="Job Description" FontAttributes="Bold" FontSize="14" HorizontalOptions="StartAndExpand"/>
                                <Label Text="{Binding .Description}" Style="{DynamicResource ListItemTextStyle}" HorizontalOptions="StartAndExpand"/>
                            </StackLayout>
                            <BoxView Color="#DCDCDC" WidthRequest="160" HeightRequest="2" />

                            <StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" VerticalOptions="EndAndExpand">
                                <Label Text="{Binding .Postedby}" HorizontalOptions="Start" Style="{DynamicResource CaptionStyle}" />
                                <!--<Image x:Name="fb_imageTag" Source="facebooklogo.png">
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer Tapped="ReadMore_Clicked" />
                                    </Image.GestureRecognizers>
                                </Image>-->
                                <Button Text="Delete" Clicked="DeleteClicked"/>
                            </StackLayout>
                        </StackLayout>

                    </DataTemplate>
                </swipecards:CardStackView.ItemTemplate>
            </swipecards:CardStackView>

The problem is the button is not clicking inside the Data template. Can you guys please help me what should i do now?

Thank you..

Hard to say what is wrong. Could you show full xaml code, view code behind and your viewmodel

Is DeleteClicked is in code behind or in VM?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM