MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.17k stars 3.43k forks source link

'MaterialDesignNavigationPrimaryListBox' resource not found. #2383

Closed Zumpel96 closed 3 years ago

Zumpel96 commented 3 years ago

I am currently creating a NavBar similar to the one in the example project.

After copy and pasting it and basically removing all of the bindings, I came up with the following code:

        <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}">
            <materialDesign:DrawerHost.LeftDrawerContent>
                <DockPanel MinWidth="220">
                    <ToggleButton 
                        Style="{StaticResource MaterialDesignHamburgerToggleButton}" 
                        DockPanel.Dock="Top"
                        HorizontalAlignment="Right" 
                        Margin="16"
                        IsChecked="{Binding ElementName=MenuToggleButton, Path=IsChecked, Mode=TwoWay}"/>

                    <ListBox
                        x:Name="NavigationItems"
                        Margin="0 16 0 16"
                        Style="{StaticResource MaterialDesignNavigationPrimaryListBox}">
                        <ListBox.ItemTemplate>
                            <DataTemplate DataType="helpers:NavigationItem">
                                <TextBlock Text="{Binding Name}" Margin="24 4 0 4" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </DockPanel>
            </materialDesign:DrawerHost.LeftDrawerContent>

            <DockPanel>
                <materialDesign:ColorZone
                    Padding="16"
                    materialDesign:ShadowAssist.ShadowDepth="Depth2"
                    Mode="PrimaryMid"
                    DockPanel.Dock="Top">
                    <DockPanel>
                        <StackPanel Orientation="Horizontal">
                            <ToggleButton
                                x:Name="MenuToggleButton"
                                Style="{StaticResource MaterialDesignHamburgerToggleButton}"
                                IsChecked="False"
                                AutomationProperties.Name="HamburgerToggleButton"/>
                        </StackPanel>
                    </DockPanel>
                </materialDesign:ColorZone>

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <ContentControl Name="ActiveItem" />
                </Grid>
            </DockPanel>
        </materialDesign:DrawerHost>

Please keep in mind that I use an MVVM framework (CM): But, the bindings work. The result does not change, when I hardcode values in the ListBox for example.

If I try to compile my code, I get an exception, that a static resource was not found and while investigating the code, Visual Studio underlines the line Style="{StaticResource MaterialDesignNavigationPrimaryListBox}" and writes 'MaterialDesignNavigationPrimaryListBox' resource not found..

Edit:// On top of that: Without this Style the elements are not displayed. For example: If I move the ListBox out of the navigation, it gets displayed. If I move it inside the navigation, nothing is displayed.

Used Version: 4.1.0

StefanoRivolta-Previero commented 3 years ago

MaterialDesignNavigationPrimaryListBox is going to be released in 4.2.0

For now you should use MaterialDesignListBox

If you cloned the project, you could create a branch that reverts to 4.1.0, like this:

devenv_LQl85IVUAq

In the bottom right corner of VS click on master, then manage branches. Open the master branch, right-click on the commit with the 4.1.0 tag, click new branch and create the new branch, with checkout selected. This way your project is on par with 4.1.0

Zumpel96 commented 3 years ago

Thanks. Solved my issue.