Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:08:02+00:00 2026-05-31T08:08:02+00:00

I have a context menu in wp7 <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu x:Name=onHoldContextMenu> <toolkit:MenuItem Header=Delete Tag={Binding} Click=DeleteVisitorNote_Click

  • 0

I have a context menu in wp7

<toolkit:ContextMenuService.ContextMenu>
    <toolkit:ContextMenu x:Name="onHoldContextMenu">
        <toolkit:MenuItem Header="Delete" Tag="{Binding}" Click="DeleteVisitorNote_Click" Visibility="{Binding DeleteContextVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <toolkit:MenuItem Header="View" Tag="{Binding}" Visibility="{Binding ViewContextVisibility, Converter={StaticResource BooleanToVisibilityConverter}}" Click="ViewVisitorContact_Click"/>
    </toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>

I amd changing the visibility for the two items in the view model, it is working fine. My problem is that when I set the visibility to false for both items, I have an empty white line when I open the context menu, and I don’t know how to hide that… I tried:

<toolkit:ContextMenuService.ContextMenu>
    <toolkit:ContextMenu x:Name="onHoldContextMenu"  Visibility="{Binding ContextVisibility, Converter={StaticResource BooleanToVisibilityConverter}}">
        <toolkit:MenuItem Header="Delete" Tag="{Binding}" Click="DeleteVisitorNote_Click" Visibility="{Binding DeleteContextVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <toolkit:MenuItem Header="View" Tag="{Binding}" Visibility="{Binding ViewContextVisibility, Converter={StaticResource BooleanToVisibilityConverter}}" Click="ViewVisitorContact_Click"/>
    </toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>

But in this case I get a nullrefference exception…

How can I hide the context menu when it is empty?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:08:04+00:00Added an answer on May 31, 2026 at 8:08 am

    I found this solution on a different forum.

            <ListBox.ItemTemplate> 
                    <DataTemplate> 
                        <Grid Hold="Grid_Hold"> 
                            <toolkit:ContextMenuService.ContextMenu> 
                                ... context menu items ... 
                            </toolkit:ContextMenuService.ContextMenu> 
    
                            ... listbox item contents ... 
    
                        </Grid> 
                    </DataTemplate> 
                </ListBox.ItemTemplate> 
    
        private void Grid_Hold(object sender, System.Windows.Input.GestureEventArgs e) 
        { 
            ItemViewModel listitem = (sender as FrameworkElement).DataContext as ItemViewModel; 
            e.Handled = listitem.DisableContextMenu(); 
        } 
    

    Setting e.Handled = true would block the ContextMenu from receiving the Hold event. In your view model you would implement some property or method that returns whether to display the ContextMenu.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so I have attached a context menu (right-click menu) to a wpf listview. unfortunately,
I have a context menu, that I'd like to change the Header based on
I have a context menu situated inside a User Control Resource. <UserControl.Resources> <ContextMenu x:Key=Menu1>
Suppose I have a context menu as a window resource: <Window.Resources> <ContextMenu x:Shared=false x:Key=ContextMenu>
I have a context menu on a TextView representing a user name in my
I'm trying to have my context menu stay on screen even after I click
I have a several MenuItem's inside a ContextMenu in my wp7 app using silverlight.
I want to have the context menu of links provide me an option to
I have a ViewModel (AbstractContextMenu) that represents my context menu (IContextMenu), and I bind
I have a listview with two columns and I'm using a context menu to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.