Question:

Coding help with XAML?

by  |  earlier

0 LIKES UnLike

im trying to get the background of my buttons to be an image. i already have the image added to the project in vs 2008 here is my code:

<Button x:Name="button1" Height="100" Width="100" Click="button1_Click">

<Button.Background>

</Button.Background>

</Button>

how do i get the image to be the background on the button?

 Tags:

   Report

1 ANSWERS


  1. Since Control.Background is of type Brush, you can use an ImageBrush.

          &lt;Button.Background&gt;

            &lt;!-- The ImageBrush&#039;s Viewport and TileMode

                 are set to produce a pattern from the

                 image. --&gt;

            &lt;ImageBrush

              Viewport=&quot;0,0,0.5,0.5&quot;

              TileMode=&quot;FlipXY&quot;

              ImageSource=&quot;sampleImages\berries.jpg&quot; /&gt;

          &lt;/Button.Background&gt;

You're reading: Coding help with XAML?

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.