How to add an image to a button?

How do I add an image to a Silverlight button?

  • Answer:

    Open SilverlightOpen Silverlight editor in Macromedia Flash, click on the form you want to edit in the workspace area titled "Solution Explorer." Move down to the area of the code file where you want to add the button image.Create Your ButtonUse the Silverlight tag to create a button image by inserting the following code: <Button x:Name="btnTest" Canvas.Top="60" Canvas.Left="30" Click="btnTest_Click" Content="Click me!"></Button> The "Canvas" dictates where the button is placed; the "click" designates the function of the button when clicked and the content decides the text in the button, which is replaced when there is an image.Insert Your Image TagPlace an image tag in between the button tags to replace the custom button image with your own. Insert the name of your button image in place of the "myButtonImage.jpg" in the following code: <Button x:Name="btnTest" Canvas.Top="60" Canvas.Left="30" Click="btnTest_Click" Content="Click me!"> <Image x:Name="buttonImage" Source="/Images/myButtonImage.jpg" Width="45" Height="45" /> </Button>References:http://www.silverlightshow.net/items/Using-the-Button-control-in-Silverlight-2-Beta-1.aspx

Answerbag Staff at Answerbag.com Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.