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

Get gorgeous, multi-touch charts for your iOS application with just a few lines of code.

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.

.Net developers: use Highcharts, the industry's leading interactive charting library, without writing a single line of JavaScript.

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}