简体   繁体   English

如何在列表框wp7中打开上下文菜单

[英]how context menu opens in listbox wp7

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. 但是在列表框中,我没有使用列表框的tap或hold事件,因此上下文菜单如何可见。

Please tell which event is firing which opens my context menu; 请告知正在触发哪个事件,这会打开我的上下文菜单; the xaml code is: xaml代码是:

<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? 请告诉我上下文菜单是如何打开的,因为我还没有使用列表框的点击或按住事件,但是当我长按列表框项目时,上下文菜单会打开吗?

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. 但是请注意,某些用户可能对此感到困惑,因为大多数用户希望单击并按住列表框项时会显示上下文菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM