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

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

问题描述

我有一个要在Silverlight中完成的项目。该项目有一个网格,有31个hyperlinkBut​​ton,命名为hyperlinkBut​​ton1-31对应于no。的日子。我试着写一个条件的状态,将改变特定的超链接按钮的特定日子的背景颜色,或者甚至更好,如果我可以选择或突出它。
所以如果日期是1月15日,那么hyperlinkBut​​ton15的背景属性将是黑色的。

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

如果任何人可以帮助,那将非常感谢。

If anyone can help, that would be very appreciated.

尊敬

/ Omar

推荐答案

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

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天全站免登陆