#341 – Create a Button with an Image and Text

Since a Button is a ContentControl, it can have any other control as its content, rather than text.  You can include an Image control, to create a button with an image on its face.  You can also include multiple controls on the button, by settings its main content to be a container, which in turn contains other controls.

In the example below, we create a Button that has both an image and some text (a caption).

        <Button HorizontalAlignment="Center" VerticalAlignment="Center"
                Margin="10" >
                <Image Source="Misc-Settings-icon.png" Height="64" Width="64"/>
                <Label Content="Settings" HorizontalAlignment="Center"/>


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #341 – Create a Button with an Image and Text

  1. Artur says:

    HI Sean,

    I repeat your example in my apps. All is ok, no errors but when aplication runs image doesn’t appear. I use VS 2012 for Desktop, my image properties.png is located in C:\…\apps_name\ImageButton\Icons\. Here is a XAML code:

    Could tell me how fix it, please ?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: