Click here to Skip to main content
14,880,257 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I built a WPF app in VS 2015 that includes a custom UserControl. Then I installed the MaterialDesignXAMLToolkit package (from nuget) and followed the instructions in Getting Started · MaterialDesignInXAML/MaterialDesignInXamlToolkit Wiki · GitHub[^] . As expected, the styling changed on many of the controls, but not everything is working as I think it should:

1) The setup instructions have me add these attributes to the MainWindow:
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Background="{DynamicResource MaterialDesignPaper}"
Visual Studio complains that it can't find those Resources. It doesn't have trouble finding the Button Style resources I applied to my UserControl. Why can't it find these two?

2) The documentation seems to indicate that I should be able to reference theme colors to use in other <Style> elements, but I have not been able to figure out how.

3) I see from available videos that I should be able to add controls from the Toolkit into my ToolBox, but when I browse to the DLLs for that purpose, there are no importable controls there.

I haven't been able to find the right instruction to fill my knowledge gap on this. What am I missing?

  • None of these are blocking me, but I want to make sure I have everything set up correctly before I start customizing things.
  • I found the answer to #2 in the Wiki.
  • I cloned the source code and got the Demo working. (It's not as easy as implied in the docs.) That has helped my understanding.
  • I'm beginning to wonder if the cause of #1 is just that the document is out of date.

    What I have tried:

    I have double-checked my execution of the instructions in the Getting Started document.
    I have confirmed the added DLLs are in the References.
    I have watched 4 introductory videos on using the Toolkit.
    Updated 13-Aug-20 0:42am
    Gerry Schmitz 12-Aug-20 12:19pm
    Just ignore those statements if it means you can't get up and running. If you can't find those 2 names using a global solution search then you are missing something but (dynamic resource) "colors" aren't the end of the world; set static ones if you have to.

    1 solution

    The MaterialDesignBody and MaterialDesignPaper styles are defined in the theme. If your running application can't find them, then it looks like you've missed part of the setup:
    A final App.xaml should look something like this:
    <Application x:Class="Example.App" ... xmlns:materialDesign="" ...>
                    <materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="DeepPurple" SecondaryColor="Lime" />
                    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> 
    If you don't have either materialDesign:BundledTheme or materialDesign:CustomColorTheme in your merged dictionaries, then the dynamic resources will not be found.
    John Whitmire 13-Aug-20 9:51am
    @Richard Deeming - Oh, if it were only that simple. Adding the Dictionaries to App.xaml is step 1 of the Getting Started instructions. They are there; if they weren't, I would not have access to the resources I am already using (styles and brushes).
    Rebuilding the libraries with the Demo app incurred a slew of warnings about things that aren't defined in the referenced namespace(s). Around half relate to Dragablz and MahApps which I don't have, so they don't concern me, but the rest hint that a large renaming effort occurred that did not get propagated to all the places it affected... like the Getting Started document. I think I know where to look now for the answer to #1, and #3 may just be a misunderstanding of what was presented in the videos.

    This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900