Sponsored By
MindStick Cleaner
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Mindstick
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
Reason:    
   

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

Ankit Singh


Total Post: 67
Member Since: 1/2/2012
Points: 323
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: 140
Member Since: 5/6/2013
Points: 983
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"/>

        <Button.Template>

            <ControlTemplate TargetType="Button">

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

            </ControlTemplate>

        </Button.Template>

    </Button>

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
Reason:    
 
Total Online Users: 2694
Advertisement
MindStick DataConverter
Advertise with Us
  
Copyright © 2014MindStick. All Rights Reserved.