0
\$\begingroup\$

So i was looking at the Monogame.Extended.GUI Project and used this instructions to set it up in a .net Core Project. So far everythings works fine. I followed the example of the demo and created a button like this

var button = new Button();
button.Content = "Button1";
button.BackgroundColor = Color.Transparent;

var demoScreen = new Screen
{
   Content = new StackPanel
   {
        Orientation = Orientation.Vertical,
        VerticalAlignment = VerticalAlignment.Centre,
        HorizontalAlignment = HorizontalAlignment.Centre,
        Items = { button }
   }
};

Now i want to give this Button a style, for example disable any mouse interactions like hover or mouse presses. The button has a HoverStyle and a PressedStyle property but i don't know how to use it.

   button.Hoverstyle = ???
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Control styles are designed to be loaded from a Skin but you can also create them in code a bit like populating a dictionary.

new ControlStyle(typeof(Control)) {
    {nameof(Control.BackgroundColor), new Color(51, 51, 55)},
    {nameof(Control.BorderColor), new Color(67, 67, 70)},
    {nameof(Control.BorderThickness), 1},
    {nameof(Control.TextColor), new Color(241, 241, 241)},
    {nameof(Control.Padding), new Thickness(5)},
    {nameof(Control.DisabledStyle), new ControlStyle(typeof(Control)) {
            { nameof(Control.TextColor), new Color(78,78,80) }
        } 
    }
}

An example of this can be found in the default skin implementation.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .