Coder Social home page Coder Social logo

Comments (4)

batzen avatar batzen commented on June 14, 2024 1

The ThemeManager in ControlzEx only provides the theming infrastructure and does not provide any built in theme or resources.

Note that by default no theming is applied to any controls. Clicking Light/Dark buttons, which call ChangeTheme have no effect.

That's because ControlzEx does not provide any colors/resources/templates/styles.

If I have to specify the colours in various controls styles, how should I reference them? I have tried things such as MahApps.Colors.Highlight and ThemeGenerator.Colors.Highlight but neither works.

You have to either use MahApps.Metro to get some styles/colors to influence or you have to build all that stuff on your own.

The only colors/resources provided by the runtime theme generator are the ones from

values.Add("ThemeGenerator.Colors.PrimaryAccentColor", runtimeThemeColorValues.PrimaryAccentColor.ToString());
and those only get supplied if the theme is really runtime generated.
Runtime generation of themes only happens if you have registered a LibraryThemeProvider.

To get an idea of what you'll have to do you can have a look at the following files/places:
https://github.com/ControlzEx/ControlzEx/blob/develop/src/ControlzEx.Showcase/Theming/ShowcaseLibraryThemeProvider.cs
https://github.com/ControlzEx/ControlzEx/blob/develop/src/ControlzEx.Showcase/Themes/Themes/GeneratorParameters.json
https://github.com/ControlzEx/ControlzEx/blob/develop/src/ControlzEx.Showcase/Themes/Themes/Theme.Template.xaml

<PackageReference Include="XAMLTools.MSBuild" PrivateAssets="All" IncludeAssets="build" />

<XAMLColorSchemeGeneratorItems Include="Themes\Themes\Theme.Template.xaml">

I hope this helps.

from controlzex.

batzen avatar batzen commented on June 14, 2024 1

The easiest way to register your themes with the provider is to do it the way it's done by MahApps.Metro, Fluent.Ribbon or the showcase application here.

Assuming you want to use the template approach (Theme.Template.xaml + GeneratorParameters.json):

  • Define your LibraryThemeProvider (call the base ctor with true)
  • In your Generic.xaml use <theming:MyLibraryThemeProvider x:Key="{x:Static theming:ShowcaseLibraryThemeProvider.DefaultInstance}" />

Assuming you want to do everything manually:

  • Use the above to ease registration
  • Add code to your app startup or in the ctor of your LibraryThemeProvider
  • Register your themes with your LibraryThemeProvider
  • Add resources to your LibraryTheme instances by calling AddResource on them

from controlzex.

will-scc avatar will-scc commented on June 14, 2024

Thanks Batzen. I suspected something like that was the case, but couldn't quite pull across all the documentation to make sense of it.

If I wanted to use pre-defined resource dictionaries for my themes, how would I do that?

The documentation only goes as far as to say:

You may also provide a custom ResourceDictionary with all the needed resources.

Get yourself a copy of the required Template
MahApps.Metro: https://github.com/MahApps/MahApps.Metro/blob/main/src/MahApps.Metro/Styles/Themes/Theme.Template.xaml
Fluent.Ribbon: https://github.com/fluentribbon/Fluent.Ribbon/blob/master/Fluent.Ribbon/Themes/Themes/Theme.Template.xaml
Replace all items surrounded by double curly braces {{ Content to Replace }}
Remember to create all needed variants. E.g.: If you want to support light and dark themes you will need to implement both.

Once I have my template(s), how do I import those into ThemeManager so they can be used?

from controlzex.

will-scc avatar will-scc commented on June 14, 2024

Thanks for the help @batzen, appreciate it. I'll give that ago.

from controlzex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.