本文介绍了以编程方式更改标签属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是我需要以编程方式更改Label FontWeight和FontStyle,但似乎无济于事……这是我到目前为止已经尝试过的方法:

The problem is that I need to change Label FontWeight and FontStyle programmatically but nothing seems to work... this is what I've tried so far:

label.FontWeight = FontWeight.FromOpenTypeWeight(99);

对于label.FontStyle我不知道,我被困在这里:

For label.FontStyle I have no idea, I got stuck here:

label.FontStyle = new FontStyle();

我不知道从那以后该怎么办.我疯狂地搜索,但什么也没找到.

I have no idea what to do from there on. I googled like crazy but found nothing.

提前感谢您的任何建议!

Thanks in advance for any suggestion!

推荐答案

对于FontStyle,可以在后面的代码中使用FontStyles类,对于FontWeight,则可以使用FontWeights.

For FontStyle you can use the FontStyles class in the code-behind, and for FontWeight use the FontWeights.

        private void Button_Click(object sender, RoutedEventArgs e)
    {
        uiLabel.FontWeight = FontWeights.Bold;
        uiLabel.FontStyle = FontStyles.Italic;
    }

这篇关于以编程方式更改标签属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 15:06