【发布时间】:2016-08-12 03:01:43
【问题描述】:
所以今天我尝试使用丰富的文本框为我漂亮的控制台日志提供一种很酷的颜色。 但是代码有很多错误
RichTextBox box = ConsoleTextBox;
box.SelectionStart = box.TextLength;
box.SelectionLength = 0;
box.SelectionColor = color;
box.AppendText(text);
box.SelectionColor = box.ForeColor;
我在 SelectionStart、TextLength、SelectionLength、SlectionColor 和 ForeColor 上遇到错误。 错误说:
RichTextBox 不包含“上述之一”的定义,并且 没有扩展方法'上述之一'
这是我的 XAML:
<Grid>
<RichTextBox Name="ConsoleTextBox"
AcceptsReturn="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Background="#FF0d0d0d"
Foreground="White"
BorderBrush="#FF282828"
BorderThickness="0,1,0,0">
</RichTextBox>
</Grid>
我做错了什么?
【问题讨论】:
-
您尝试访问的属性属于普通文本框而不是富文本框
-
@Joseph 那你怎么解释呢? stackoverflow.com/questions/10587715/…
-
@Bitsec 这个问题与 WPF 或 Win 形式有关吗?