I processed the same script using the BehaviorsSDK. This SDK makes life easier by adding the ability to call a function for an event. Just add the link to your project in the BehaviorsSDK, and then add the method to the item data class for each event. Here is an example:
ObservableCollection<ItemModel> Items; public class ItemModel { public bool No_Positive_Likes ... public bool No_Negative_Likes ... public void LikeButtonPressed() { ... } public void DislikeButtonPressed() { ... } }
Then in your xamll:
xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:core="using:Microsoft.Xaml.Interactions.Core" ... <GridView ItemsSource={Binding}> <GridView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <AppBarButton Icon="Like" Name="like" IsCompact="True"> <i:Interaction.Behaviors> <core:EventTriggerBehavior EventName="Click"> <core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="LikeButtonPressed"/> </core:EventTriggerBehavior> </i:Interaction.Behaviors> </AppBarButton>
source share