473,670 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ico n>
<Image Source="Resourc es\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.Ico n>
<Image Source="Resourc es\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 10934
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.Ico n>
<Frame Source="Resourc es\LogIn.xaml">
</MenuItem.Icon>
</MenuItem>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"David Veeneman" <da****@nospam. comwrote in message
news:OY******** ******@TK2MSFTN GP04.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.Ico n>
<Image Source="Resourc es\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.Ico n>
<Image Source="Resourc es\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
1268
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? Thanks, J G
3
6787
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
1242
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, Excel 2003 and VS2003.NET have these icons. I've looked in the properties with the menubars in the toolkit & there is no hint how it is acheived. Would I need to download & install another component to make my menu items have pictures alongside...
10
21298
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 sender As System.Object, _ ByVal e As System.EventArgs) _ Handles mnuTopics_Show.Select Dim mShowMenuItem As MenuItem mShowMenuItem = DirectCast(sender, MenuItem)
3
1320
by: Sumit Gupta | last post by:
How to Add Images to Menu Items in .Net Sumit
1
1212
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, when my menu items have thier property OwnerDrawn set to true I have to draw menu items and text inside each menu items by myself. All that works fine, but how do I get the black right triangle drawn as well?
8
2101
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 I do that? For example in outlook express, when one expand a main menu item and holds mouse over one of the enable sub menu item, one would see some sort microhelp text in the status bar in the bottom
2
5902
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 commands to the control's context menu? I'm envisioning a case where the control has a set of context menu items, and the parent form also has a set of context menu items. Thanks.
1
1056
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 the standard windows ICONS and GIFS that can be used within the Windows menus BUTs allow the background colour to be changable to fit in within your specific application mleekirkham@hotmail.com
13
2848
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 witch object was selected. This is the sub procedure that read the items from an Array and create the menutitem. The array hold more information to use in program when one of the items is selected. Dim finisharray(,) As String ' is set up...
0
8388
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8907
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8817
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8593
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8663
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5687
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.