473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Vector icons in WPF menu items?

I'm just getting started with WPF and XAML, and I am trying to create a
traditional menu bar. Everything works until I get to the menu icons. I can
add a bitmap icon to a menu item using this XAML markup:

<MenuItem Header = "Log In">
<MenuItem.Icon>
<Image Source="Resources\LogIn.png" />
</MenuItem.Icon>
</MenuItem>

However, I want to use vector graphics, rather than bitmaps, for menu icons.
So, I try this markup:

<MenuItem Header = "Log In">
<MenuItem.Icon>
<Image Source="Resources\LogIn.xaml" />
</MenuItem.Icon>
</MenuItem>

I'm getting a design-time error saying that "No imaging component suitable
to complete this operation was found".

What's going on, and what do I need to do to be able to use a XAML
vector-graphic file as a menu item icon? Thanks for your help!

David Veeneman
Foresight Systems
Dec 20 '07 #1
2 10919
David,

I don't believe you can use an Image tag here, because the Image will
expect something in an image format.

Rather, you could place the markup for the vector right in the Icon
property. Either that, or set it as a static resource somewhere in your
project, and then set the Icon to that static resource.

You might be able to use a Frame as well, like so:

<MenuItem Header = "Log In">
<MenuItem.Icon>
<Frame Source="Resources\LogIn.xaml">
</MenuItem.Icon>
</MenuItem>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Veeneman" <da****@nospam.comwrote in message
news:OY**************@TK2MSFTNGP04.phx.gbl...
I'm just getting started with WPF and XAML, and I am trying to create a
traditional menu bar. Everything works until I get to the menu icons. I
can add a bitmap icon to a menu item using this XAML markup:

<MenuItem Header = "Log In">
<MenuItem.Icon>
<Image Source="Resources\LogIn.png" />
</MenuItem.Icon>
</MenuItem>

However, I want to use vector graphics, rather than bitmaps, for menu
icons. So, I try this markup:

<MenuItem Header = "Log In">
<MenuItem.Icon>
<Image Source="Resources\LogIn.xaml" />
</MenuItem.Icon>
</MenuItem>

I'm getting a design-time error saying that "No imaging component suitable
to complete this operation was found".

What's going on, and what do I need to do to be able to use a XAML
vector-graphic file as a menu item icon? Thanks for your help!

David Veeneman
Foresight Systems

Dec 21 '07 #2
Thank you, Nicholas! That is exactly what I needed.
Dec 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jon Gabel | last post by:
Do any of you beta users of .NET 2.0 know if bitmaps/icons are supported for main menu items? I saw a screenshot of a sample app that had this feature. Does .NET CF 2.0 have this support too? ...
3
by: Heather | last post by:
I notice the Tag property for menu items. Is there a way to assign say a 1 to the Tag property of certain menu items and then make those menu items not visible programatically? Thanks! Heather
1
by: Dinesh Narayan | last post by:
Hello, I'm writing an application with Visual Studio 2003.NET using C++, I'm hoping someone could tell me how to make icons appear in menubars next menu items. Windows apps like Office Word 2003,...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
3
by: Sumit Gupta | last post by:
How to Add Images to Menu Items in .Net Sumit
1
by: Dino Buljubasic | last post by:
Hi, My application has a menu with some of the menu items that have their own menu items. By default, VB will add a black right rectangle when a menu items has its own menu items. However,...
8
by: gs | last post by:
I was able to set tooltips on objects other than main menu. I would like to get the effect of tooltip or microhelp in the bottom status bar when the mouse is hovering over a submenu item. How do...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
1
by: martin99 | last post by:
I am led to believe that you cant use ICO in VB Menu items buit have to use GIF/JPG if so how do I get the background to the same colour as my windows.....Is there software out there that has all...
13
by: PetterL | last post by:
I writing a program where I read menu items from a file. But I have problem when I click an menu item i want it to mark that one as checked but I cant access the menu object of that item to see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.