我正在尝试使 WPF 文本块上的每一行文本以不同的颜色显示。我有以下代码使整个块的字体颜色为紫色,因为这是它设置的最后一种颜色。我怎样才能使每种药水都以不同的颜色显示?
private void btnShowPotions_Click(object sender, RoutedEventArgs e) {
tbPotionInfo.Foreground = Brushes.Green;
tbPotionInfo.Text = smallPotion.Name + "(" + smallPotion.AffectValue + ")\r\n";
tbPotionInfo.Foreground = Brushes.Blue;
tbPotionInfo.Text += mediumPotion.Name + "(" + mediumPotion.AffectValue + ")\r\n";
tbPotionInfo.Foreground = Brushes.Red;
tbPotionInfo.Text += largePotion.Name + "(" + largePotion.AffectValue + ")\r\n";
tbPotionInfo.Foreground = Brushes.Purple;
tbPotionInfo.Text += extremePotion.Name + "(" + extremePotion.AffectValue + ")\r\n";
}