0

I use Template Studio WPF to autogenerate the template of my UI. In the "ShellViewModel" I set up the HamburgerMenuItem container

public ObservableCollection<HamburgerMenuItem> MenuItems { get; } = new ObservableCollection<HamburgerMenuItem>()
{
new HamburgerMenuGlyphItem() { Label = Resources.ShellMainPage, Glyph = "\uE8A5", TargetPageType = typeof(MainViewModel) },
new HamburgerMenuGlyphItem() { Label = Resources.ShellListDetailsPage, Glyph = "\uE8A5", TargetPageType = typeof(ListDetailsViewModel) },
};

Now I want to replace HamburgerMenuGlyphItem with HamburgerMenuIconItem or HamburgerMenuImageItem.

new HamburgerMenuIconItem() { Label = Resources.ShellListDetailsPage, Icon = Resources.ExcelParserIcoNeu, TargetPageType = typeof(ListDetailsViewModel) },

With Resources.ExcelParserIcoNeu I get an Object of Type System.Drawing.Icon defined in my Resources.

Here is the output of my HamburgerMenuIconItem

what HamburgerMenuIconItem does

As you can see, it does not render the Icon correctly.

Then I tried to use HamburgerMenuImageItem to do the job.

new HamburgerMenuImageItem(){ Label = Resources.ShellExcelParserPage, Thumbnail= new BitmapImage(new Uri(ExcelJpg)), TargetPageType = typeof(ExcelParserViewModel) }

with

static string ExcelJpg = "pack://application:,,,/Images/excelparsericoneu.jpg";

there I get the error message at runtime that path of the image can not be resolved. The Folder "Images" is part of my Project and contains the file as you can see in the following picture.

Project tree

If I pass the absolute path it works correctly.

I googled a lot regarding this topic but wars not able to find a solution.

Can you please help me with my issues or point me in the right direction?

thanks, alot.

Martin
  • 41
  • 4

1 Answers1

0

Now I figured out on part of my problem. HamburgerMenuImageItem was not able to find the image at the specified location becaus I didn`t set the buildprocess setting of the image to ressource. Due to this the image was not at "pack://application:,,,/Images/excelparsericoneu.jpg" and I got a runtime error.

Martin
  • 41
  • 4