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 8700941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:17:06+00:00 2026-06-13T02:17:06+00:00

I want to hide a menuItem regarding user’s rights. The menu item is placed

  • 0

I want to hide a menuItem regarding user’s rights. The menu item is placed into a context menu (displayed with a right click) into a userControl. Rights are passed to the user control trough the main window. I have an error 40 : Binding error. VS can’t find my property declared in the xaml document.

MainWindow.xaml

<MyUC:myUC
    ...
    MainOptionsVisibility="False" />

myUc.xaml

<GMap_NET_WindowsPresentation:GMapControl.ContextMenu>
                <ContextMenu Opened="ContextMenu_Opened">
                    <MenuItem
                        Header="{x:Static Internationalization:Resources.VIEWPORT_ADDOBJECT}"
                        Command="{x:Static local:Viewport.CreateGraphicObjectRequestCommand}"
                        CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                        Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
                        <MenuItem.Icon>
                            <Image Source="{DynamicResource EditIcon}" Width="32" Height="32" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="{x:Static Internationalization:Resources.OPTIONS}"
                             Visibility="{Binding Path=MainOptionsVisibility, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" >
                             ...
                     />
            </GMap_NET_WindowsPresentation:GMapControl.ContextMenu>
        </GMap_NET_WindowsPresentation:GMapControl>

And MainOptionsVisibility is well declared as dependency property in code-behind. I have checked, it is well initialized. The visibility of the other item is OK (I didn’t do it).

EDIT : new XAML code after Flo’s answer :

<UserControl
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:Main.Client.MyProject.Implementation.UIs.StandardViewports.Viewports"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:GMap_NET_WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
         xmlns:Internationalization="clr-namespace:Main.Client.MyProject.Library.Resources;assembly=MyProjectLibrary"
         xmlns:Main_Client_MyProject_Library_Converters="clr-namespace:Main.Client.MyProject.Library.Converters;assembly=MyProjectLibrary"
         x:Name="baseViewport"
         x:Class="Main.Client.MyProject.Implementation.UIs.StandardViewports.Viewports.Viewport"
         MouseEnter="baseViewport_MouseEnter"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300" Loaded="BaseViewport_Loaded">
<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/MyLibs;component/ResourceDictionnary/ResourceDictionnary.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <Main_Client_MyProject_Library_Converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
        <Main_Client_MyProject_Library_Converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityTestConverter" />
    </ResourceDictionary>
</UserControl.Resources>
<UserControl.CommandBindings>
    ...
</UserControl.CommandBindings>
<Grid>
    <GMap_NET_WindowsPresentation:GMapControl
        x:Name="gMapControl"
        MaxZoom="18"
        MinZoom="1"
        MouseDown="gMapControl_MouseDown"
        OnMapZoomChanged="gMapControl_OnMapZoomChanged"
        OnCurrentPositionChanged="gMapControl_OnCurrentPositionChanged"
        MouseMove="gMapControl_MouseMove"
        Loaded="gMapControl_Loaded"
        Drop="gMapControl_Drop"
        AllowDrop="True"
        IsEnabled="{Binding IsEnabled, ElementName=baseViewport}" MapType="OpenStreetMap">
        <GMap_NET_WindowsPresentation:GMapControl.ContextMenu>
            <ContextMenu Opened="ContextMenu_Opened">
                <MenuItem
                    Header="{x:Static Internationalization:Resources.VIEWPORT_ADDOBJECT}"
                    Command="{x:Static local:Viewport.CreateGraphicObjectRequestCommand}"
                    CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                    Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityTestConverter}}">
                    <MenuItem.Icon>
                        <Image Source="{DynamicResource EditIcon}" Width="32" Height="32" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{x:Static Internationalization:Resources.VIEWPORT_OPTIONS}"
                         Visibility="{Binding Path=PlacementTarget.DataContext.MainOptionsVisibility, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Converter={StaticResource BooleanToVisibilityTestConverter}}" >
                    <MenuItem Header="{x:Static Internationalization:Resources.VIEWPORT_LOCKSUPERIORLEFTCORNER}" Command="{x:Static local:Viewport.LockSuperiorLeftCornerRequestCommand}" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}">

                    </MenuItem>
                    <MenuItem Header="{x:Static Internationalization:Resources.VIEWPORT_LOCKINFERIORRIGHTCORNER}" Command="{x:Static local:Viewport.LockInferiorRightCornerRequestCommand}" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}">

                    </MenuItem>
                    <MenuItem Header="{x:Static Internationalization:Resources.VIEWPORT_LOCKZOOMMAXONMAP}" Command="{x:Static local:Viewport.LockMaxZoomLevelRequestCommand}" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" >
                    </MenuItem>
                    <MenuItem Header="{x:Static Internationalization:Resources.VIEWPORT_LOCKZOOMMINONMAP}" Command="{x:Static local:Viewport.LockMinZoomLevelRequestCommand}" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" >
                    </MenuItem>
                </MenuItem>

            </ContextMenu>
        </GMap_NET_WindowsPresentation:GMapControl.ContextMenu>
    </GMap_NET_WindowsPresentation:GMapControl>
</Grid>

The converter was changed for both menuItems for tests. It is never called.

  • 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-06-13T02:17:07+00:00Added an answer on June 13, 2026 at 2:17 am

    The problem is your MenuItem has no property which is called MainOptionsVisibility, only your Window has. Through RelativeSource={RelativeSource Self} your Binding to the MenuItem.

    RelativeSource={RelativeSource AncestorType={x:Type Window}} wont work either, because your ContextMenu isnt part of the Windows logical or visual Tree.

    What you could do is set the DataContext of the ContextMenus PlacementTarget (GMap_NET_WindowsPresentation:GMapControl) or one of its ancestors to your Window (e.g. through setting the Windows DataContext to itself (<Window ...DataContext={Binding RelativeSource={RelativeSource Self}}.../>) and the do something like:

    <MenuItem Header="{x:Static Internationalization:Resources.OPTIONS}" Visibility="{Binding Path=PlacementTarget.DataContext.MainOptionsVisibility, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to hide the Admin Panel menu item from visitor, without going into
I have a menu item that I want to show/hide only if the user
I have multilingual website in joomla and want to hide one menu item (not
Whenever a user clicks a menu item I want to show a tooltip: //
I want to hide the download folder location so that when the user downloads
Basically, I have a button and on click it displays a menu. I want
I want to have a menu that when I click replaces the content of
Ok I have a status menu application with a Hide menu item in it.
I want to hide any LI in .social-menu that have blank hrefs. I originally
I've written a Firefox extension which appends a menuitem onto the context menu and

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.