'How do you make a new FlatButtonAppearance object?

I'm running into a frustratingly stupid problem with the FlatButtonAppearance object, which apparently has a constructor that I can't find any information about.

It doesn't seem to have any defined constructors, and doesn't inherit from anything - I was under the impression that the compiler would generate a blank constructor public FlatButtonAppearance() {}, however that doesn't appear to be the case.

Whenever I try creating a FlatButtonAppearance object using any of the following methods:

FlatButtonAppearance flatAppearance = new();
FlatButtonAppearance flatAppearance = new()
{
    BorderSize = 1,
    BorderColor = Color.Transparent,
    CheckedBackColor = Color.Transparent,
    MouseDownBackColor = Color.Transparent,
    MouseOverBackColor = Color.Transparent
};

It throws this error:

error CS1729: 'FlatButtonAppearance' does not contain a constructor that takes 0 arguments

So clearly it does have a constructor, however neither intellisense nor MSDN will tell me what its signature is.
Even Visual Studio's metadata doesn't show a constructor.

The only way that I can find that actually works is this:

FlatAppearance flatAppearance = new Button().FlatAppearance;

but Button has to get that from somewhere too, and creating an entire button control just so I can use the FlatAppearance property is just a dirty hack.

Is there something I'm missing here?



Solution 1:[1]

Based on your response comment, you could do something like this:

public abstract class TabHeaderButtonBase : ButtonBase
{
    public TabHeaderButtonBase() : base()
    {
        /* You'll probably want this as well... */
        FlatStyle = FlatStyle.Flat;

        FlatAppearance.BorderSize = 1;
        FlatAppearance.BorderColor = Color.Transparent;
        FlatAppearance.CheckedBackColor = Color.Transparent;
        FlatAppearance.MouseDownBackColor = Color.Transparent;
        FlatAppearance.MouseOverBackColor = Color.Transparent;

        /* And any other defaults... */
    }
}

Then use this type as the base for your custom buttons.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1