Click here to Skip to main content
15,888,190 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, i want to display only an image in the content of button.

I have a class:
C#
public class MyButton : Button
{
    //here i want to describe a style to view only an image for button content
}
Posted
Updated 21-Jan-13 4:00am
v2

You can override the button style in the App.xaml.

See this blog entry[^] or the MSDN entry[^]. You can place a picture box inside of the button and disable the other graphics around it. I don't know the exact way from scratch but the two links should give you a good start.

cheers,
Marco Alessandro Bertschi
 
Share this answer
 
Comments
Gianluca Palmieri 22-Jan-13 3:40am    
Thank you for your answer Marco!
Hi Marco,

How about using an ImageButton?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.aspx[^]

Cheers,
Edo
 
Share this answer
 
Comments
Marco Bertschi 22-Jan-13 3:51am    
This would not be a good solution.
Since he is asking for a WPF solution (stated in the question tags) I thought I'll point him towards the WPF solution for the problem.

If you are using an Image Button for many of your Button controls and later there are some requirement changes who might want to have a descriptive text near the image you would kinda run into problems because you would have to exchange all the image buttons. And a further fact is that an image button is a Web-Control but WPF is a client technology. So there is no "System.Web.UI.WebControls.ImageButton" available for WPF Projects.

cheers,
Marco Alessandro Bertschi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900