以编程方式选择超链接按钮

发布于 2024-12-29 04:47:32 字数 625 浏览 3 评论 0原文

我有一个项目要在 Silverlight 中完成。该项目有一个包含 31 个 hyperlinkBut​​ton 的网格,这些按钮被命名为 hyperlinkBut​​ton1-31,对应于编号。一月的天数。我正在尝试编写一个条件语句,该语句将在特定日期更改特定超链接按钮的背景颜色,或者如果我可以选择或突出显示它就更好了。 因此,如果这一天是 1 月 15 日,那么 hyperlinkBut​​ton15 的背景属性将为黑色。

我认为它应该做到这一点但它给我错误的代码是:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的往事 2025-01-05 04:47:32

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

您写了以下行:

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

Colors.Black 属性需要用括号括起来,如下所示:

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文