How to access a page's datacontext from inside a listview?

Viewed 906

I am using MVVM Cross to build a UWP application. I am having trouble binding a command to a button. Previously in the XAML page I used an interactivity to bind other commands. The issue here is that we are using a listview to present a user's "favorite list." The UnfavoriteCommand is in the ViewModel but never gets hit because User.Favorite list is in a model and does not have the "UnfavoriteCommand." How do I handle this binding issue using MVVM Cross?

            <ListView 
                Grid.Row="0"
                Grid.Column="0"
                CanReorderItems="True"
                CanDrag="True"  
                AllowDrop="True"
                ItemsSource="{Binding User.FavoriteList}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="500" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="0" Grid.Row="0"
                                        HorizontalAlignment="Left"
                                        Margin="0, 0, 0, 0"
                                        Height="25" >
                                    <TextBlock Text="{Binding Description, Mode=TwoWay}"
                                                   VerticalAlignment="Center"
                                                   TextAlignment="Left"/>
                                </StackPanel>
                                <StackPanel VerticalAlignment="Center" Grid.Column="1" Grid.Row="0">
                                    <Button Content="&#xf00d;" 
                                            FontFamily="{StaticResource FontAwesomeFontFamily}"                                                
                                            BorderBrush="Black">

                                        <Interactivity:Interaction.Behaviors>
                                            <Core:EventTriggerBehavior EventName="Click">
                                                <Core:EventTriggerBehavior.Actions>
                                                    <Core:InvokeCommandAction CommandParameter="{Binding}" Command="{Binding UnfavoriteCommand}"/>
                                                    <!--<Core:CallMethodAction TargetObject="{Binding}" MethodName="Unfavorite" />-->
                                                    <!--<Core:InvokeCommandAction Command="{Binding UnfavoriteCommand}" InputConverter="{StaticResource buttonConverter}"/>-->
                                                </Core:EventTriggerBehavior.Actions>
                                            </Core:EventTriggerBehavior>
                                        </Interactivity:Interaction.Behaviors>
                                    </Button>
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
2 Answers
Related