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 3:54am
Edited 21-Jan-13 4: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 Dnyaneshwar@Pune 604
1 thatraja 370
2 OriginalGriff 319
3 Sergey Alexandrovich Kryukov 241
4 Gihan Liyanage 194
0 OriginalGriff 737
1 Dnyaneshwar@Pune 604
2 Kornfeld Eliyahu Peter 505
3 Sergey Alexandrovich Kryukov 372
4 thatraja 370


Advertise | Privacy | Mobile
Web03 | 2.8.140902.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