Search code examples
c#windows-phone-8windows-phonecontextmenulonglistselector

LongListSelector with ContextMenu


I am actually trying to implement a ContextMenu in a LongListSelector in my Windows Phone 8 app. This is what I am doing. I can't understand why the context menu is not showed at all. How do I make it work? :/

<phone:LongListSelector Name="Storico" HorizontalAlignment="Left" Height="384" Margin="39,254,0,0" VerticalAlignment="Top" Width="406" BorderBrush="#FFFF2800" Tap="Storico_Tap">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" Width="420" Height="40" Foreground="#FFFF9000" FontSize="30" ManipulationStarted="TextBlock_ManipulationStarted" ManipulationCompleted="TextBlock_ManipulationCompleted"/>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu Name="ContextMenu" >
                                <toolkit:MenuItem Name="Watch" Header="Watch Trailer"/>
                                <toolkit:MenuItem Name="Buy" Header="Buy"/>
                                <toolkit:MenuItem Name="Share" Header="Share"/>
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>

Thanks in advance


Solution

  • Tried adding ContextMenu to TextBlock?

    <TextBlock Text="{Binding Name}" Width="420" Height="40" Foreground="#FFFF9000" FontSize="30" ManipulationStarted="TextBlock_ManipulationStarted" ManipulationCompleted="TextBlock_ManipulationCompleted">
        <toolkit:ContextMenuService.ContextMenu>
            <toolkit:ContextMenu Name="ContextMenu" >
                <toolkit:MenuItem Name="Watch" Header="Watch Trailer"/>
                <toolkit:MenuItem Name="Buy" Header="Buy"/>
                <toolkit:MenuItem Name="Share" Header="Share"/>
            </toolkit:ContextMenu>
        </toolkit:ContextMenuService.ContextMenu>
    </TextBlock>