Programmatically selecting hyperlinkbuttons

牧云@^-^@ 提交于 2019-12-12 03:12:15

问题


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:


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);


来源:https://stackoverflow.com/questions/9013561/programmatically-selecting-hyperlinkbuttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!