Click here to Skip to main content
Rate this: bad
good
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
v2
Rate this: bad
good
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.
 
cheers,
Marco Alessandro Bertschi
  Permalink  
Comments
gpalmieri84 at 22-Jan-13 3:40am
   
Thank you for your answer Marco!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi Marco,
 
How about using an ImageButton?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.aspx[^]
 
Cheers,
Edo
  Permalink  
Comments
Marco Alessandro Bertschi at 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)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
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