0

我正在尝试在我的 Windows 应用商店应用程序中使用 Visual Basic 在运行时更改文本块的前景色。但是,我不知道正确的方法。请协助。

我写的是:

TextBlock1.Foreground = Windows.UI.Colors.Red

它说“'Windows.UI.Color' 类型的值不能转换为'Windows.UI.Xaml.Media.Brush'。”

我已经尝试了所有这些:

TextBlock1.Foreground = "Red"
TextBlock1.Foreground = "#FFC8C8C8"
TextBlock1.Foreground = &HFF0000FF&
TextBlock1.Foreground = &H0000FF&

我想我显然错过了正确的方法。任何帮助表示赞赏。(:

4

1 回答 1

1

你需要给它分配一个SolidColorBrushColor

Dim redBrush As New SolidColorBrush
redBrush.Color = Windows.UI.Colors.Red
TextBlock1.Foreground = redBrush
于 2012-10-28T09:17:11.680 回答