The background does not change with the theme.

Hi, I have a MenuAdv and use SfSkinManager to change themes.  When I do, the menu backgrounds do not change with the theme.

I found an earlier thread that describes this problem ( MenuItemAdv Background not change | WPF Forums | Syncfusion ), but the solution in that thread -- effectively to hardcode colors -- is not a solution for dynamically switching themes.

I was able to trace the issue to the presence of a Style in my container style.  Without this ItemContainerStyle, menus render correctly, but I lose my bindings.

        <syncfusion:MenuAdv Grid.Row="0" DockPanel.Dock="Top" Height="30" ItemsSource="{Binding MenuItems}">

            <syncfusion:MenuAdv.ItemContainerStyle>

                <Style TargetType="{x:Type syncfusion:MenuItemAdv}">

                    <Setter Property="Command" Value="{Binding Command.Value}" />

                    <Setter Property="IsEnabled" Value="{Binding IsEnabled.Value}" />

                    <Setter Property="InputGestureText" Value="{Binding InputGesture.Value}" />

                </Style>

            </syncfusion:MenuAdv.ItemContainerStyle>

            <syncfusion:MenuAdv.ItemTemplate>

                <HierarchicalDataTemplate DataType="{x:Type itwpf:MenuItemViewModel}" ItemsSource="{Binding Path=MenuItems}">

                    <TextBlock Text="{Binding Header.Value}"/>

                </HierarchicalDataTemplate>

            </syncfusion:MenuAdv.ItemTemplate>

        </syncfusion:MenuAdv>


I'm new to WPF, apologies in advance for any failures in my understanding, but I found alternate xaml that works correctly in all respects, except that the menus themselves render with correct colors, but as large blocks, not laid out as you'd expect a menu to appear.

        <syncfusion:MenuAdv Grid.Row="0" DockPanel.Dock="Top" Height="30" VerticalAlignment="Top" ItemsSource="{Binding MenuItems}">

            <syncfusion:MenuAdv.ItemTemplate>

                <HierarchicalDataTemplate DataType="{x:Type itwpf:MenuItemViewModel}" ItemsSource="{Binding MenuItems}">

                    <MenuItem

                      Command="{Binding Command.Value}"

                      IsEnabled="{Binding IsEnabled.Value}"

                      InputGestureText="{Binding InputGesture.Value}"

                      Header="{Binding Header.Value}"

                    />

                </HierarchicalDataTemplate>

            </syncfusion:MenuAdv.ItemTemplate>

        </syncfusion:MenuAdv>


The attached project shows a window with two menu bars, one for each xaml approach listed, and showing the relative issues with each.

Can either of these versions be made to appear correct?


Attachment: ThemedMenuTest_b8cdcb9c.zip

4 Replies

MJ Madhumithan Jayapathi Syncfusion Team October 9, 2023 01:16 PM UTC

Hi David,

We have reviewed your query, and we have been working on changing the background color of the MenuAdv with theme changes. Unfortunately, we have not found a workaround for this behavior so far. We are currently investigating possible solutions, and we are considering logging this as a feature request.

We will continue to explore this issue and provide you with comprehensive details on or before October 11, 2023. We appreciate your patience until then.


Regards,
Madhumithan Jayapathi



MJ Madhumithan Jayapathi Syncfusion Team October 10, 2023 11:02 AM UTC

Hi David,

We have reviewed your query, and currently, there is no direct support to change the background of the MenuItemAdv. However, you can maintain the color of the MenuItemAdv in accordance with different themes by updating the ResourceDictionary. We have attached a sample for your reference, and please let us know if you need any further assistance.

Regards,

Madhumithan Jayapathi


Attachment: ThemedMenuTest_d682b3a5.zip


NE Neil January 7, 2024 04:41 PM UTC

How would I do this with MVVM like in the attached solution?


Attachment: MenuSkinning_77627de0.zip


BS Bhaskar Suresh Syncfusion Team January 10, 2024 05:47 PM UTC

Hi Neil,


We have modified the sample by updating the ResourceDictionary to achieve your requirement. Please refer to the attachment sample for your reference.


Regards,

Bhaskar Suresh


Attachment: MenuSkinning_34b602a1.zip

Loader.
Up arrow icon