以编程方式选择超链接按钮
我有一个项目要在 Silverlight 中完成。该项目有一个包含 31 个 hyperlinkButton 的网格,这些按钮被命名为 hyperlinkButton1-31,对应于编号。一月的天数。我正在尝试编写一个条件语句,该语句将在特定日期更改特定超链接按钮的背景颜色,或者如果我可以选择或突出显示它就更好了。 因此,如果这一天是 1 月 15 日,那么 hyperlinkButton15 的背景属性将为黑色。
我认为它应该做到这一点但它给我错误的代码是:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的编码中有一个简单的错误。
您写了以下行:
Colors.Black 属性需要用括号括起来,如下所示:
You have a simple error in your coding.
You wrote the following line:
The Colors.Black property needs to be surrounded in parentheses, like this: