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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:39:50+00:00 2026-05-18T09:39:50+00:00

I have some images that I use as icons for ContextMenu Items: <UserControl.Resources> <Image

  • 0

I have some images that I use as icons for ContextMenu Items:

<UserControl.Resources>
    <Image x:Key="DeleteIco" Source="pack://application:,,,/MyProject.myControl;component/Resources/Delete.ico" Width="16" Height="16"/>
    ...
    <ContextMenu x:Key="MyMenu1">
        <MenuItem Header="Delete" Icon="{StaticResource DeleteIco}"/>
    </ContextMenu>

    <ContextMenu x:Key="MyMenu2">
        <MenuItem Header="Delete me" Icon="{StaticResource DeleteIco}"/>
    </ContextMenu>
<UserControl.Resources>

Sometimes the first menu miss the icon, sometimes the second… why? I don’t do anything on the icons in the code.

  • 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-18T09:39:50+00:00Added an answer on May 18, 2026 at 9:39 am

    You have created an Image control, and tried to put it twice in the visual tree. Since all controls can only have one parent your Image got disconnected. Thus using it a second time, the first will be disconnected, resulting in your missing icon.

    You can resolve this, by not adding the Image, but the ImageSource instead to your resources:

    <BitmapImage x:Key="DeleteIco" UriSource="pack://application:,,,/MyProject.myControl;component/Resources/Delete.ico" />
    

    Your menu has to change a bit for it to work though:

    <ContextMenu x:Key="MyMenu1">
        <MenuItem Header="Delete">
             <MenuItem.Icon>
                  <Image Source="{StaticResource DeleteIco}" Width="16" Height="16"/>
             </MenuItem.Icon>
        </MenuItem>
    </ContextMenu>
    
    <ContextMenu x:Key="MyMenu2">
        <MenuItem Header="Delete me">
             <MenuItem.Icon>
                  <Image Source="{StaticResource DeleteIco}" Width="16" Height="16"/>
             </MenuItem.Icon>
        </MenuItem>
    </ContextMenu>
    

    Update:

    You can also use styles to set some basic properties of the Image for you

    <Style TargetType="Image">
        <Setter Property="Width" Value="16"/>
        <Setter Property="Width" Value="16"/>
    </Style>
    

    Or use a Style for MenuItem to set the Icon each time.

    <Style TargetType="MenuItem" x:Key="DeleteMenuIcon">
        <Setter Property="Icon">
            <Setter.Value>
                 <Image Source="{StaticResource DeleteIco}" Width="16" Height="16"/>
            </Setter.Value>
        </Setter>
    </Style>
    

    And the MenuItem:

    <MenuItem Header="Delete me" Style="{StaticResource DeleteMenuIcon}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some static resources (images and HTML files) that will be localized. One
I want to use custom barbutton that will have some image. I am doing
I have some images that are wrapped within containers like this: <div id=swatchcontainer> <div
I have some images that need to change, based not only on hover, but
I have some text/images that I only want to display in the normal state
I have been working on a website that has some images that I need
I have a div with id=images. The div contains some images that are each
I have an app that will show some images using UIImageView, now I want
I have a thread that downloads some images from internet using different proxies. Sometimes
I have third party sites that link to some images on my site. The

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.