Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

QA: Changing the Border color of Grid element in Silverlight and Windows Phone

DZone's Guide to

QA: Changing the Border color of Grid element in Silverlight and Windows Phone

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

Yesterday I have received the following question by Juhee:

I want to change the gray color of a grid to orange.I was able to change the thickness by changing the margin but do you know how to change the color of the grid? So, for example:


<Grid Background="Black"  Margin="5,5,5,5">
    <StackPanel Width="318" Orientation="Horizontal">
        <StackPanel Width="145" Orientation="Vertical">
            <TextBlock TextWrapping="Wrap" Text="{Binding Text}" FontSize="20"/>
            <Image Source="{Binding Photopath}" Opacity="{Binding Dimness}"/>
        </StackPanel>
    </StackPanel>
</Grid>

If you would like to change the Background color of your grid then, simply, modify Background attribute of the grid (Background=”Black”, as you did that in your code).

If you want to change the color of a Grid’s border color or thickness you have to place your grid inside a Border element. Check my sample bellow:

<Border BorderThickness="5" BorderBrush="Orange">
    <Grid Background="Black"  Margin="5,5,5,5">
        <StackPanel Width="318" Orientation="Horizontal">
            <StackPanel Width="145" Orientation="Vertical">
                <TextBlock TextWrapping="Wrap" Text="{Binding Text}" FontSize="20"/>
                <Image Source="{Binding Photopath}" Opacity="{Binding Dimness}"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</Border>
I hope that answers your question.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}