Take the 2-minute tour ×

I have a project to be done in Silverlight. The project has a grid with 31 hyperlinkButtons that are named hyperlinkButton1-31 corresponding to the no. of days in january. I'm trying write a conditioned statment that will change the background color of a specific hyperlinkbutton in a specific day, or even better if i can select or highlight it. So if the day is 15 of january then the background property of hyperlinkButton15 will be black.

The code which i think it should do it but it is giving me error is:-

enter code here

    protected override void OnNavigatedTo(NavigationEventArgs e)
        int d;
        d = DateTime.Today.Day;
        int i;
           if (i==d)
              (hyperlinkButton{0},i).background= new SolidColorBrush(Colors.Black); //Here it should be something like this but i'm not sure how to do it

If anyone can help, that would be very appreciated.



share|improve this question
add comment

1 Answer

You have a simple error in your coding.

You wrote the following line:

(hyperlinkButton{0},i).background= new SolidColorBrushColors.Black);

The Colors.Black property needs to be surrounded in parentheses, like this:

hyperlinkButton.Background = new SolidColorBrush(Colors.Black);
share|improve this answer
Sry i have parentheses in my original code. The problem for me is the left side of = as it should be hyperlinkButton26.Background tho the hyperlinkButton26 should be automatically choosen. Any idea how to do that? –  DreamNet Jan 26 '12 at 10:53
I'm sorry, you're not making any sense to me. What are you trying to ask? –  James Didzun Jan 26 '12 at 23:15
I'm really sry that i might not be that clear in what i'm trying to do, anyhow i will try my best to explain. I have a project that has a grid and inside this grid there is 31 hyperlinkButtons named hyperlinkButton1-31. The program should check which day is it eg. 25 and then change the background color of the hyperlinkButton that corrospond to that day number in this case "hyperlinkButton25". Because the day number change every 24 hour, i can't write hyperlinkButton25.background in my code, Other than i have to find a way to let the program match the day number with the hyperlinkButton number –  DreamNet Jan 27 '12 at 9:10
An addition to my previous comment:- ie. if the day is 25 then the hyperlinkButton25 will change, if it is 16 then hyperlinkButton16 will change. Is there anyway to do that? Hope this explain my question better ;) –  DreamNet Jan 27 '12 at 9:17
add comment

Your Answer


