Programmatically selecting hyperlinkbuttons

2019-09-12 03:43发布

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:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    int d;
    d = DateTime.Today.Day;
    int i;
    for (i = 1; i <= d; 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
         }
     }

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-09-12 04:23

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);
查看更多
登录 后发表回答