Mården
Mården

Reputation: 31

How to change grid color with a button click?

I've trying to create an app in Windows Phone 8 that changes the color of a Grid when a button is clicked, and I could use some help.

I've searched around the web, but can't seem to find any answer that satisfies my need.

All I have currently is this:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    Random random = new Random();
    int number = random.Next(0, 1);

    if (number == 1)
    {
        yesornogrid.Background = SolidColorBrush 
    }
}

Upvotes: 0

Views: 1030

Answers (1)

Native_Mobile_Arch_Dev
Native_Mobile_Arch_Dev

Reputation: 777

use the following name space:

using System.Windows.Media;

And then try:

yesornogrid.Background = new SolidColorBrush([Some Color]);

For Example:

yesornogrid.Background = new SolidColorBrush(Colors.Orange);

Upvotes: 2

Related Questions