public class ThemeProperty
{
public Color FColor { get; set; } = Color.White;
public Color BColor { get; set; } = Color.Black;
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public ThemeProperty Theme { get; set; } = new ThemeProperty();
// Use.
public void Test()
{
Theme.BColor = Color.Gray;
Theme.FColor = Color.Black;
Theme = true; /*I wanted to make the feature active or passive, but
I could not figure out how to define a property class for this line.*/
}
嗨,我創建了一個名爲Theme的可擴展屬性。雖然我有兩個功能,但如果我處於主動或被動狀態,我想使用它們,如果我處於活動狀態,我想使用它們。我可以創建和控制此功能,但它不靈活。我想像上面那樣定義這個特性,但是我不知道如何去做。非常感謝您的幫助。C#展開式屬性
我想在紅線上添加真假值。激活或停用功能。
我試圖用這種方式解釋我還沒有靈活。謝謝你的回覆,我會組織這個問題。 – Emre