hansgiller
hansgiller

Reputation: 1051

howto add context menu to stackpanel in wp7?

i have a listbox with a datatemplate 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?

Upvotes: 1

Views: 853

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 65564

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

Upvotes: 2

Related Questions