我正在尝试在包含 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 的行为方式相同?