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\$
0
\$\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\$
  • \$\begingroup\$ Thank you, that worked 👍 \$\endgroup\$ – Ultralord Jul 15 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.