1
votes

I have a list box in which when i long-press the particular item of the listbox, a context menu opens. But in the listbox i have not used tap or hold event of listbox so how my context menu is visible.

Please tell which event is firing which opens my context menu; the xaml code is:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ListBox x:Name="scheduleListbox" ItemsSource="{Binding scheduleList}" Tap="scheduleListbox_Tap">
        <ListBox.ItemTemplate>
            <DataTemplate>
               <StackPanel Orientation="Vertical" Height="150" Width="460">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu >
                            <toolkit:MenuItem Header="Add To Calendar" Click="AddToCalendar_Click" />
                            <toolkit:MenuItem Header="View Description" Click="ViewDescription_Click" />
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                    <TextBlock x:Name="textBlock1" Text="{Binding ScheduleName}" Foreground="WhiteSmoke" FontSize="32"/>
                    <TextBlock x:Name="textBlock2" Text="{Binding ScheduleDate}" Foreground="Red" Margin="0,10,0,0"/>
                    <StackPanel Orientation="Horizontal" Height="70" Width="460">
                        <TextBlock x:Name="textBlock3" Text="{Binding StartTime}" Margin="0,5,0,0"/>
                        <TextBlock x:Name="textBlock4" Text="{Binding EndTime}" Margin="50,5,0,0"/>
                    </StackPanel>
                </StackPanel>

            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</Grid>

Please tell how my context menu is open as i haven't used tap or hold event of listbox but when I long-press the listbox item, the context menu opens?

1

1 Answers

2
votes

By default, the context menu opens on long hold, it is by design. If you wish to open it any other way, you must write your own logic. For examples on how to do that, see these threads:

But be aware that some users might be confused by this since most users will expect that the context menu will be shown when you tap and hold the list box item.