跳到主要内容

GetBackgroundColor

返回当前内容控件的背景颜色。

语法

expression.GetBackgroundColor();

expression - 表示 ApiInlineLvlSdt 类的变量。

参数

此方法没有任何参数。

返回值

ApiColor

示例

获取文档中容器的边框颜色。

// How can I get the background color using an inline content control in a document?

// Get the background color for an inline content control in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let inlineLvlSdt = Api.CreateInlineLvlSdt();
let run = Api.CreateRun();
inlineLvlSdt.SetBackgroundColor(Api.RGBA(0, 0, 255, 40));
let color = inlineLvlSdt.GetBackgroundColor();
run.AddText("BackgroundColor: " + (color ? color.GetHex() : "none"));
inlineLvlSdt.AddElement(run, 0);
paragraph.AddInlineLvlSdt(inlineLvlSdt);

inlineLvlSdt = Api.CreateInlineLvlSdt();
run = Api.CreateRun();
color = inlineLvlSdt.GetBackgroundColor();
run.AddText("BackgroundColor: " + (color ? color.GetHex() : "none"));
inlineLvlSdt.AddElement(run, 0);
paragraph.AddInlineLvlSdt(inlineLvlSdt);