简体   繁体   English

如何在C#中为AvalonEdit设置画布背景颜色

[英]How to set the canvas background color for AvalonEdit in C#

I want to have different background colors for the AvalonEdit control but although I see solutions for coloring individual lines I cannot seem to find one just to set the entire background color. 我想为AvalonEdit控件提供不同的背景颜色,但是虽然我看到了对单个线条进行着色的解决方案,但我似乎找不到一个只是为了设置整个背景颜色。 Usually this is a simple task in most controls. 通常这在大多数控件中都是一项简单的任务。 The obvious property seemed to be 显而易见的属性似乎是

ICSharpCode.AvalonEdit.TextEditor.Background ICSharpCode.AvalonEdit.TextEditor.Background

For example if my AvalonEdit control is called "TheEditor" I wish a line something like 例如,如果我的AvalonEdit控件被称为“TheEditor”,我希望有一个类似的行

TheEditor.Background=..... TheEditor.Background = .....

But I cannot seem to get it to accept anything even when setting it to a new instance of it's class. 但即使将它设置为它的类的新实例,我也似乎无法接受任何东西。

I am very new to C# (this is my first project) and can't help thinking I'm missing something fundamental. 我是C#的新手(这是我的第一个项目)并且不禁想到我错过了一些基本的东西。

I've found the correct usage for this property; 我找到了这个属性的正确用法;

Example : 示例:

         ThisEditor.Background =  System.Windows.Media.Brushes.Red;

There was another brush type within my scope (System.Windows.Drawing.Brush) that was also causing some confusion until I fully qualified the path from "Brushes.Red" to "System.Windows.Media.Brushes.Red" 在我的范围内有另一个画笔类型(System.Windows.Drawing.Brush),这也引起了一些混乱,直到我完全限定从“Brushes.Red”到“System.Windows.Media.Brushes.Red”的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM