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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:07:55+00:00 2026-05-22T21:07:55+00:00

Im having a problem rendering icons for a dynamic menu which uses viewmodels as

  • 0

Im having a problem rendering icons for a dynamic menu which uses viewmodels as an ItemsSource.
The solution I’ve used is outlined here
MVVM Dynamic Menu UI from binding with ViewModel

The basic layout is as follows

<Grid>
  <Grid.Resources>
    <HierarchicalDataTemplate DataType="{x:Type ViewModels:HeaderedItemViewModel}"
        ItemsSource="{Binding Path=Children}">
      <ContentPresenter RecognizesAccessKey="True"></ContentPresenter>
    </HierarchicalDataTemplate>
    <Style TargetType="{x:Type MenuItem}">
      <Setter Property="Header" Value="{Binding Path=Header}" />
      <Setter Property="InputGestureText" Value="{Binding Path=InputGestureText}" />
      <Setter Property="Command" Value="{Binding Path=Command}" />
      <Setter Property="Icon">
        <Setter.Value>
          <Image Source="{Binding Path=Icon}" Height="16px" Width="16px" />
        </Setter.Value>
      </Setter>
    </Style>
  </Grid.Resources>
  <Menu Grid.Row="0" ItemsSource="{Binding Path=Shell.Navigation.Menus}" />
</Grid>

In the above style the binding ‘Icon’ is ‘ImageSource’. This is set up as follows.

        BitmapImage image = null;

        if (!string.IsNullOrEmpty(imagePath))
        {
            image = new BitmapImage(new Uri(imagePath, UriKind.Relative));
            image.CacheOption = BitmapCacheOption.OnLoad;
            image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
        }
        var menu = new HeaderedItemViewModel
                       {
                           Header = header,
                           InputGestureText = inputGesture,
                           ImagePath = imagePath,
                           Icon = image,
                           Command = command,
                           IsEnabled = isEnabled
                       };

The problem I’m having is with the icons.
It seems only one icon will render at a time? Heres what I mean.

enter image description here

And opening the dropdown menu …

enter image description here

As soon as another image is rendered the first one disappears? In other words only the last image is visible. This happens with all the images in the menu. Any ideas?

  • 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-22T21:07:56+00:00Added an answer on May 22, 2026 at 9:07 pm

    Add x:Shared=false for your Icon value.
    To do that you should declare Image in resources:

    <Grid>
      <Grid.Resources>
    
       <Image x:Key="imgCTX" x:Shared="false"
             Source="{Binding Path=Icon}" Height="16px" Width="16px"/>
        <HierarchicalDataTemplate DataType="{x:Type ViewModels:HeaderedItemViewModel}"
            ItemsSource="{Binding Path=Children}">
          <ContentPresenter RecognizesAccessKey="True"></ContentPresenter>
        </HierarchicalDataTemplate>
        <Style TargetType="{x:Type MenuItem}">
          <Setter Property="Header" Value="{Binding Path=Header}" />
          <Setter Property="InputGestureText" Value="{Binding Path=InputGestureText}" />
          <Setter Property="Command" Value="{Binding Path=Command}" />
          <Setter Property="Icon" Value="{StaticResource imgCTX}" />
        </Style>
      </Grid.Resources>
      <Menu Grid.Row="0" ItemsSource="{Binding Path=Shell.Navigation.Menus}" />
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, here's a problem I'm having. I have Lua bindings to a rendering engine
I am having a problem rendering my view in the layout page using mvc
Im having a problem with Hotmail's email rendering. And im looking for an answer
I'm having a problem with this error: Caught NoReverseMatch while rendering: Reverse for ''pennies.views.seed_preview''
I'm having problem with rendering depth in OpenGL Following code is a simple example
I'm having troubles with rendering response via AJAX. Here is how my .js.haml view
I am having problem with rendering text/json in Chrome. I use YUI library to
I am having what seems to be a mipmapping problem when rendering textures on
I'm having a strange problem which I cannot figure out for the life of
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how

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.