Click here to Skip to main content
Rate this: bad
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
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 at 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 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
Your Filters
0 Sergey Alexandrovich Kryukov 372
1 OriginalGriff 295
2 thatraja 215
3 Emre Ataseven 155
4 Shai Vashdi 125
0 Sergey Alexandrovich Kryukov 8,849
1 OriginalGriff 5,035
2 Peter Leow 3,949
3 Maciej Los 3,535
4 Abhinav S 3,148

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