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

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.
Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}