I want to create a simple button template with an image and text inside it. But I want to keep the System button’s look and feel.
How do I create it, step by step?
P.S.: I have already tried it with CustomControl in WPF and BasedOn property.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this easily with a style and attached property:
and
Then in markup:
This example looks pretty hideous, but you can easily change the
StackPanelto aGridor something similar to constrain the image proportion. Using theContentPresenterallows you to preserve the behaviour of a button allowing you to put anyUIElementinside, and retaining Command support etc.