Image Brush Background set in Windows Phone 7

In this article you will learn about how to set Background using Image Brush in Windows Phone 7.
  • 7066

Image Brush

The ImageBrush object is assigned to the AlbumData object's ImageBrush property so that the appropriate image is displayed in the application. Although the remainder of the code won't be shown here, the sample project available contains everything you'll need to see how users can interact with an album once it's rendered. As you can see below, the  background is applied as an image with an ImageBrush, If you use a background image, its Build Action should be set to Resource to ensure that it is shown as soon as the first page of the application starts.


    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    <!--LayoutRoot is the root grid where all page content is placed-->
            <ImageBrush ImageSource="a.jpg" /> 

// Mainpage.xaml.vb code

Imports System.Windows.Media.Imaging

Partial Public Class MainPage
    Inherits PhoneApplicationPage
    ' Constructor
    Public Sub New()
    End Sub
    Public Sub CreateAnImageBrush()
        ' Create a Rectangle
        Dim blueRectangle As New Rectangle()
        blueRectangle.Height = 100
        blueRectangle.Width = 200 
        ' Create an ImageBrush
        Dim imgBrush As New ImageBrush()
        imgBrush.ImageSource = New BitmapImage(New Uri("a.jpg", UriKind.Relative))
        ' Fill rectangle with an ImageBrush
        blueRectangle.Fill = imgBrush
    End Sub
End Class 

Output Window

Background set using Image Brush in Windows Phone 7.gif


Hope this article help you to understand how to set Background using Image Brush in Windows Phone 7.


More Articles

© 2020 DotNetHeaven. All rights reserved.