Hi all,
Considering the XAML bellow, I have a page (StorePage) and ListView which has a DataTemplateSelector that renders different templates.
Inside I have a button that must call a command declared in the page's ViewModel.
The questions is: How can I get the page's BindingContext reference inside ?
Example:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="ProductTemplate"> <controls:ProductCell> <local:ProductListItemTemplate /> </controls:ProductCell> </DataTemplate> <DataTemplate x:Key="MapTemplate"> <ViewCell> <local:LocationTemplate /> </ViewCell> </DataTemplate> <local:StoreTabTemplateSelector x:Key="TabTemplateSelector" Template1="{StaticResource ProductTemplate}" Template2="{StaticResource MapTemplate}"/> </ResourceDictionary> </ContentPage.Resources> <StackLayout Spacing="0"> <ListView x:Name="ListView" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource TabTemplateSelector}" RefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}" HasUnevenRows="True" CachingStrategy="RecycleElement"> <ListView.Behaviors> <b:EventToCommandBehavior EventName="ItemAppearing" Command="{Binding LoadMoreCommand}" EventArgsParameterPath="Item" /> </ListView.Behaviors> </ListView> </StackLayout>