【发布时间】:2011-12-15 16:27:38
【问题描述】:
我正在尝试在包含 TextBlocks 和 TextBlocks 作为 CheckBoxes 内容的页面上设置文本样式
我想做这样的事情(其中 textBlock 是 CheckBox 中包含的 TextBlock - 或继承自 System.Windows.Controls.Control 的任何内容)
textBlock.Inlines.Add("unstyledText");
textBlock.Inlines.Add(new Run { Text = "yellowBoldText ", Foreground = new SolidColorBrush(Colors.Yellow), FontWeight = FontWeights.Bold });
textBlock.Inlines.Add("unstyledText");
这适用于不在 CheckBox 内的 TextBlock。如果它们在 CheckBox 内,则 TextBlock 的 Text 属性会发生变化(即 textBlock.Text == "unstyledText yellowBoldText unstyledText" 返回 true),但 CheckBox 中的文本不会在视觉上发生变化。
有没有办法让 CheckBox 中的 TextBlocks 的行为方式与其他 TextBlocks 相同?
【问题讨论】:
-
此时是一个 State 属性,您可以对其进行检查,如果是这样,您可能需要从那里设置它..
标签: c# silverlight checkbox textblock inlines