以编程方式选择超链接按钮 [英] Programmatically selecting hyperlinkbuttons

查看:51
本文介绍了以编程方式选择超链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要在Silverlight中完成的项目。该项目有一个网格,其中包含31个超链接按钮,这些按钮分别名为no超链接按钮1-31。一月的天数。我正在尝试编写条件语句,该条件语句将在特定日期更改特定超链接按钮的背景颜色,如果我可以选择或突出显示它,甚至会更好。
因此,如果一天是一月15日,则超链接Button15的背景属性将为黑色。

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
         }
     }


推荐答案

您的编码中有一个简单的错误。

You have a simple error in your coding.

您编写了以下一行:


(hyperlinkBut​​ton {0},i).background = new SolidColorBrushColors.Black);

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

Colors.Black属性需要用括号括起来,像这样:

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

hyperlinkButton.Background = new SolidColorBrush(Colors.Black);

这篇关于以编程方式选择超链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆