Sponsored By
MindStick SurveyManager
Advertise with Us
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form

Home >> .Net >> WPF(Windows Presentation Foundation)/XAML >> Convert image to a button WPF
Author Post

Ankit Singh

Total Post: 81
Member Since: 1/2/2012
Points: 393
Convert image to a button WPF
Posted On: 9/21/2013 6:42:50 AM

I understand that i can overlay an image on a button, but is it possible that a button can take the exact size of an image? In other words, I want to get rid of the rectangular shaped button and adapt it to the size and shape of the image.

Author Post

Sumit Kesarwani

Total Post: 305
Member Since: 5/6/2013
Points: 2138
Re: Convert image to a button WPF
Posted On: 9/21/2013 7:40:01 AM
Hi Ankit,

You can set the Template of button like below:

    <Button >

        <Image Source="pan-left.png"/>


            <ControlTemplate TargetType="Button">

                <ContentPresenter Content="{TemplateBinding Content}"/>




TemplateBinding is used to set the Content property in order to set the Content inside the ControlTemplate, as you can move this ControlTemplate to the Resources and can use it for multiple button and you can set the content on button itself.

Report Abuse Form
Total Online Users: 4808
MindStick DataConverter
Advertise with Us
Copyright © 2009 - 2014MindStick. All Rights Reserved.