Click here to Skip to main content
11,928,985 members (58,259 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# WPF
Hi, i want to display only an image in the content of button.

I have a class:
public class MyButton : Button
    //here i want to describe a style to view only an image for button content
Posted 21-Jan-13 4:54am
Edited 21-Jan-13 5:00am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

Marco Alessandro Bertschi
gpalmieri84 22-Jan-13 3:40am
Thank you for your answer Marco!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Marco,

How about using an ImageButton?[^]

Marco Alessandro 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.

Marco Alessandro Bertschi

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100