Hi,
I need to change settings for Wisej.Web.MonthCalendar on current loaded Theme. I don’t want to edit the theme (I’ve already done that, but users change theme at runtime). I want to write a function (c#) to change at runtime, no matter what theme is loaded, the backcolor, forecolor, etc for Wisej.Web.MonthCalendar BoldedDates.
It is a post with BoldedDates.zip, and that theme works perfect. I need to make those changes by code.
Can anyone help?
I attached a printscreen with location of what I want to do in Theme editor.
In Wisej.NET you can change theme elements at runtime using the Application.Theme object. Application.Theme gives you a dynamic object (like a JObject) representing the active theme. You can navigate its hierarchy (settings, fonts, images, appearances, etc.) and assign new values. The theme structure matches your theme JSON (e.g. Bootstrap-4.json).
Here are some examples:
Application.Theme.Fonts["default"]["size"] = 15;
Application.Theme.Appearances["button"]["states"]["default"]["styles"]["backgroundColor"] = "#ff0000";
For your case with the monthcalendar, you can just mimic the structure from the theme mixin that I provided earlier:
Application.Theme.Appearances["datechooser"]["components"]["day"]["states"]["bolded"]["styles"]["backgroundColor"] = "lightgreen";
Additionally, these changes will be overwritten whenever you change the theme-so you’ll need to run the code again whenever the theme changes.
Hi Adrian,
please find documentation about mixins here
https://docs.wisej.com/theme-builder/getting-started/edit-a-mixin
Best regards
Frank
You can do this by using a theme mixin.
{
"name": "calendarmixin",
"appearances": {
"datechooser": {
"components": {
"day": {
"states": {
"bolded": {
"styles": {
"css": "{\"font-weight\":\"900 !important\", \"overflow\":\"visible !important\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}",
"backgroundColor": "lightgreen"
},
}
}
}
}
}
}
}
The theme mixin will only override part of the theme, allowing users to change the theme and always see the green background on bolded dates.
For more information on theme mixins see here: https://docs.wisej.com/theme-builder/getting-started/edit-a-mixin
Please login first to submit.