Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Theme dynamically #3749

Open
ShehabFekry opened this issue Dec 24, 2024 · 1 comment
Open

Change Theme dynamically #3749

ShehabFekry opened this issue Dec 24, 2024 · 1 comment
Labels
question Old items with this tag will be automatically closed.

Comments

@ShehabFekry
Copy link

ShehabFekry commented Dec 24, 2024

Bug explanation

I have a resource dictionary with this values assigned

<ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" /> <materialDesign:BundledTheme BaseTheme="Dark" PrimaryColor="LightBlue" SecondaryColor="LightBlue" /> </ResourceDictionary.MergedDictionaries>

I want to create a toggle button to change the value of the BaseTheme and primary and secondary colors using MVVM i binded the toggle to a method as shown below

               var pallete = new PaletteHelper();
               var theme = pallete.GetTheme();

when i try to get the theme i get this exception

System.InvalidOperationException: Could not locate required resource with key(s) 'MaterialDesign.Brush.Primary.Light

My project is a class library Revit plugin with some WPF views I don't have an App.xaml file

Version

5.1

@ShehabFekry ShehabFekry added bug evaluation required Items is pending review or evaluation by the team labels Dec 24, 2024
@Keboo
Copy link
Member

Keboo commented Jan 3, 2025

Hi @ShehabFekry
I did up a small example of managing theming from a class library. You can see the sample here:
https://github.com/Keboo/MaterialDesignInXaml.Examples/tree/68b4feebf1cdca0f0229d3b7b184e8ea0a1cf3f0/Theming/ThemingInClassLib

@Keboo Keboo added question Old items with this tag will be automatically closed. and removed bug evaluation required Items is pending review or evaluation by the team labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Old items with this tag will be automatically closed.
Projects
None yet
Development

No branches or pull requests

2 participants