New appearance in Theme mixin does not work

0
0

Hi,
I’m trying to define an appearance (patientMenuButton1) in a mixin, using the Material-3 theme. However, when I set the AppearanceKey property of the control (a button) to the newly-defined appearance, no change is seen.
In the same mixin, if I define a new color (buttonFace2), I can see it even in the designer and set it correctly.

What am I doing wrong?

At the same time, during the startup of the application I see several missing appearance warnings in the developer tools of Chrome. I attach the screenshot. Could this be related?

Best reagrads,
Alex

The code is
{
“name”: “Material-3.mixin”,
“fonts”: {
“default”: {
“size”: 18,
“family”: [ “roboto”, “verdana”, “arial” ]
}
},
“colors”: {
“buttonFace2”: “#F1F5F2”
},
“appearances”: {
“patientMenuButton1”: {
“text”: “Patient Menu Button”,
“inherit”: “menubutton”,
“states”: {
“default”: {
“properties”: {
“show”: “both”
},
“styles”: {
“backgroundColor”: “red”
}
},
“pressed”: {
“styles”: {
“transform”: null
}
},
“hovered”: {
“styles”: {
“backgroundColor”: “red”
},
“properties”: {
“cursor”: “pointer”
}
}
}
}
}
}

  • You must to post comments
0
0

That’s correct. Button1 sets the BackColor and ForeColor. Reset the properties and it will use the theme. Changing the AppearanceKey doesn’t remove the property values set by the app.

Attachment
  • Alex Prinias
    Yep, that was my misunderstanding… I thought I had them reset when I had set them to their default values! All good, fixed!
  • You must to post comments
0
0

Have a look at the attached project, one window with tho buttons with both having the AppearanceKey set to the same value, only one is actually affected.
A

Attachment
  • You must to post comments
0
0

I’m not sure I understand the issue. The properties are serialized when their value is set and different from the base value. I tried adding removing the AppearanceKey but those properties, if not set before, they remain not set and show the color from the theme. If you want to reset the properties right click on it and select Reset.

  • You must to post comments
0
0

Thank you, Luca.

Following your answer, I added a new button on my form and set its AppearanceKey to the one I defined in the mixin and it works indeed without a problem. So why not for the “old” buttons which are already on my form?

Well, I think I found what the problem is. Before playing with the appearances, I had tried changing the Forecolor and Backcolor “by hand” in the properties of those “old” buttons. But the hovering effect cannot be added through the properties in the designer, so I decided to create the mixin. Before applying the mixin, I reset the Forecolor and Backcolor to their original values @buttontext and @buttonface by double clicking in the properties row, opening the color picker form and selecting the @buttontext and @buttonface colors from the Theme Colors. But what that did, was to introduce those lines in the .designer.cs file. For a new button, those lines are not present, as they are considered defaults which do not need to be explicitly included. As soon as I removed those lines for the “old” buttons from the .designer.cs file, the appearance workd correctly.

So, if I set the color values back to their defaults and the lines are inserted in the .designer.cs, somehow they intervene with the appearance, the AppearanceKey is probably ignored! I could have seen there was a difference if I had noticed that in the properties, the colors I set show up in bold @buttonface and @buttontext, although these are their default values, see the attachment.

Best,
Alex

Attachment
  • You must to post comments
0
0

The missing appearances warnings are normal. There are hundreds of child widgets that don’t have a specific appearance defined in the theme.

I tried your mixin and works fine. Recopied it below.

{
 "name": "Material-3.mixin",
 "fonts": {
 "default": {
 "size": 18,
 "family": [ "roboto", "verdana", "arial" ]
 }
 },
 "colors": {
 "buttonFace2": "#F1F5F2"
 },
 "appearances": {
 "patientMenuButton1": {
 "text": "Patient",
 "inherit": "menubutton",
 "states": {
 "default": {
 "properties": {
 "show": "both"
 },
 "styles": {
 "backgroundColor": "red"
 }
 },
 "pressed": {
 "styles": {
 "transform": null
 }
 },
 "hovered": {
 "styles": {
 "backgroundColor": "red"
 },
 "properties": {
 "cursor": "pointer"
 }
 }
 }
 }
 }
}
Attachment
  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.