howto add context menu to stackpanel in wp7?
i have a listbox with a data开发者_如何学编程template that looks like this:
spackpanel
textbox1
textbox2
/stackpanel
how i want to add a context menu, so i modified it like:
spackpanel
contextMenu
contextMenuItem
/contextMenu
textbox1
textbox2
/stackpanel
i gave no additional attributes like heigh etc. only the text/content and header attributes.
when i start it, i see the textboxe's but the contextMenu is not accessable when i hold it. does i make it right? where to find good examples with stackpanel and contextMenu?
Without seeing your code/xaml it's hard to say. But, the following works for me:
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="option 1" />
<toolkit:MenuItem Header="option 2" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Text="first" Style="{StaticResource PhoneTextExtraLargeStyle}" />
<TextBlock Text="second" Style="{StaticResource PhoneTextExtraLargeStyle}" />
</StackPanel>
Styles added to increase hit target size
精彩评论