Working with Image Buttons
As we seen in the older post Buttons are very important user elements and in this app we are going to see how to change normal buttons into Image Buttons.
Its very simple here in Visual Studio 2010 to change the properties of any element by using the properties box.
here we just added a Button for our learning purpose You can learn how to work with buttons here
Its very simple here in Visual Studio 2010 to change the properties of any element by using the properties box.
here we just added a Button for our learning purpose You can learn how to work with buttons here
Now click on the button and go to Properties window of Button usually present right side of Visual Studio.Now go to Brush property of button in properties box.
Note for changing color of any UI element like TextBox or TextBox or Button or anything you have to change the Brush property of properties box.
In the case of Button we have three properties in Brush category like Background,Border Brush,Fore ground where the Foreground is the color of the Text visible in the button.To create a Image Button we have to go to background property and click on the ImageBrush button which have a mountain like icon in it as shown in diagram below.
Now you can see select image button.It will open choose image toolbox.From that choose Image from your hard drive and click on Ok button.
But for getting a beautiful button we prefer to give BorderBrush property as transparent then only you can enjoy image button's beauty.
Here is the sample image button we created
Here is the sample code for Image Button we created
<Button Content="" HorizontalAlignment="Left" Margin="100,92,0,0" VerticalAlignment="Top" Height="220" Width="281">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="/v.png"/>
</Button.Background>
</Button>