Search

Thursday, May 1, 2014
0 comments

How to put an image into a Button in WPF

1:16 AMThursday, May 1, 2014

Introduction

Window Presentation Foundation support Rich Composition, in which you can use a control as a container. In this example i will show, how to put an image into a Button control. If you want to make highly visualize application, must use WPF, because of the strict separation of appearance and behavior you can easily change the look of a control. Now, lets take an simple example

Source Code (xaml file)


<Grid>
    <Button>
        <StackPanel Orientation="Horizontal" Width="155">
                <Image Source="home.jpg " Height="33" Width="66" Stretch="Uniform"/>
            <TextBlock Text=" Home" FontSize="20"/> 
            
 </StackPanel>
    </Button>
    </Grid>

Code Generate the following output

According to above mentioned source code, A Button control contains a stack panel so its work as a container. We already learn about stack panel in previous article. In client based application you can design more powerful application using WPF.

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top