Forum Xamarin.Forms

TapGestureRecognizer command not called

This is my xaml page

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="http://prismlibrary.com"
             xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
             xmlns:ffTransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
             xmlns:controls="clr-namespace:InstagroomEX.Controls"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="InstagroomEX.Views.HomePageView"
             Title="Home"
             BackgroundColor="ForestGreen"
             NavigationPage.HasNavigationBar="False"
             x:Name="root">

    <StackLayout>
        <CollectionView ItemsSource="{Binding Images}">
            <CollectionView.Header>
                <StackLayout Orientation="Vertical">
                    <CollectionView ItemsSource="{Binding Source={x:Reference root}, Path=BindingContext.ImagesPath}"
                            HeightRequest="80"
                                    Margin="4,0,0,0">
                        <CollectionView.Header>
                            <Grid HeightRequest="80"
                                  WidthRequest="80">

                                <controls:SquareImage Source="{Binding Source={x:Reference root}, Path=BindingContext.UserAvatarPath, Mode=OneWay}"
                                                      Aspect="AspectFill"
                                                      Margin="8,8,8, 8">
                                    <controls:SquareImage.Transformations>
                                        <ffTransformations:CircleTransformation />
                                    </controls:SquareImage.Transformations>
                                </controls:SquareImage>
                                <controls:SquareImage Source="AddPlus.jpg"
                                                      HorizontalOptions="End"
                                                      VerticalOptions="End"
                                                      HeightRequest="16"
                                                      WidthRequest="16"
                                                      Margin="0,0,8,8">
                                    <ff:CachedImage.Transformations>
                                        <ffTransformations:RoundedTransformation Radius="1000"/>
                                    </ff:CachedImage.Transformations>
                                </controls:SquareImage>
                            </Grid>
                        </CollectionView.Header>



                    <CollectionView.ItemsLayout>
                        <LinearItemsLayout Orientation="Horizontal"
                                           ItemSpacing="0" />
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Grid HeightRequest="80"
                                  WidthRequest="80">

                                    <controls:SquareImage Source="{Binding .}"
                                                      Aspect="AspectFill"
                                                      Margin="8, 8">
                                        <controls:SquareImage.Transformations>
                                            <ffTransformations:CircleTransformation BorderSize="16" BorderHexColor="#e300b9"/>
                                        </controls:SquareImage.Transformations>
                                    </controls:SquareImage>
                                </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
                    <BoxView BackgroundColor="#524b50" HeightRequest="1"/>
                </StackLayout>

            </CollectionView.Header>


            <CollectionView.ItemsLayout>
                <LinearItemsLayout ItemSpacing="8"
                                 Orientation="Vertical"/>
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Orientation="Vertical">
                        <StackLayout Orientation="Horizontal">
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="{Binding Source, Mode=OneWay}"
                                            HeightRequest="40"
                                            WidthRequest="40"
                                            Margin="12,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CircleTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>

                            <Label Text="Username" 
                                   FontSize="18"
                                   VerticalOptions="Center"/>

                        </StackLayout>
                        <ff:CachedImage Aspect="AspectFill"                                        
                                        Source="{Binding Source, Mode=OneWay}"/>
                        <StackLayout Orientation="Horizontal">
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="Like.png"
                                            HeightRequest="36"
                                            WidthRequest="40"
                                            Margin="12,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CropTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="comment.png"
                                            HeightRequest="40"
                                            WidthRequest="40"
                                            Margin="0,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CropTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>
                        </StackLayout>
                        <Label Text="Понравилось: M"
                               FontSize="18"
                               FontAttributes="Bold"
                               Margin="12,0,0,0"/>
                        <Label LineBreakMode="WordWrap"
                               BackgroundColor="Aquamarine"
                               HorizontalTextAlignment="Start"
                               Margin="12,0,12,0">
                            <Label.FormattedText >
                                <FormattedString>
                                    <Span Text="username: "
                                          FontSize="14"
                                          FontAttributes="Bold">
                                    </Span>
                                    <Span
                                        Text="{Binding Source={x:Reference root}, Path=BindingContext.PostUserDescription, 
                                        Mode=OneWay}"/>
                                    <Span Text="{Binding Source={x:Reference root}, Path=BindingContext.LoadMoreUserDescription, 
                                        Mode=OneWay}"
                                          FontSize="14"
                                          TextColor="Red">
                                        <Span.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding Source={x:Reference root}, Mode=OneWay, Path=BindingContext.ExecuteLoadMoreUserDescriptionCommand}" />
                                        </Span.GestureRecognizers>
                                    </Span>

                                </FormattedString>
                            </Label.FormattedText>
                        </Label>
                        <Label Text="More"
                               FontSize="16"
                                TextColor="Red"
                                Margin="12,0,0,0"
                                HorizontalOptions="Start"
                                VerticalOptions="Center"/>
                        <Label Text="show all () comments"
                                HorizontalOptions="Center"
                                VerticalOptions="Center"
                                FontSize="12"
                                TextColor="Red"/>


                    </StackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </StackLayout>

</ContentPage>

And my ExecuteLoadMoreUserDescriptionCommand command doen't invoke from my ViewModel. other elements bind without problems. What is wrong with my binding?

Best Answer

Answers

Sign In or Register to comment.