Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

ContentView bindable Command

$
0
0

Hi !

In my ContentView, there is a ListView that is assigned the ItemTapped command using the EventToCommandBehavior:

<ListView x:Name="ItemsView"                  
                    ItemTemplate="{StaticResource DataTemplate.JobObject}"
                    ItemsSource="{Binding DayInfo.Items}"
                    RowHeight="{Binding ItemHeight}"
                    HeightRequest="{Binding ColumnHeight}">

                    <ListView.Behaviors>
                        <behaviors:EventToCommandBehavior EventName="ItemSelected"
                                                          Command="{Binding ItemTappedCommand}"                                                       
                                                          EventArgsConverter="{StaticResource SelectedItemConverter}"/>
                    </ListView.Behaviors>
                </ListView>

Then I created a BindableProperty in ContentView that links my command:

public static readonly BindableProperty ItemTappedCommandProperty = BindableProperty.Create(
            "ItemTappedCommand",
            typeof(ICommand),
            typeof(ColumnView));

public ICommand ItemTappedCommand
        {
            get => (ICommand) GetValue(ItemTappedCommandProperty);
            set => SetValue(ItemTappedCommandProperty, value);
        }

But when I try to link a property from ContentPage then my CommandProperty always is null. I tried to process the command in this ContentView and everything works fine, but the binding does not work.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>