Home > OS >  Material-design-in-xaml: The background of Context Menu is transparent
Material-design-in-xaml: The background of Context Menu is transparent

Time:04-10

enter image description here

I've been trying to figure this out for an hour now. As you can see, when I right-click on a textbox, the shown context menu has a transparent background. How to fix this?

This is what I have in my App.xaml

<Application
    x:Class="TEST.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TEST"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles/Color.xaml" />
                <ResourceDictionary Source="Styles/ErrorMessage.xaml" />
                <ResourceDictionary Source="Images/LogoBanner.xaml" />
                <materialDesign:CustomColorTheme
                    BaseTheme="Light"
                    PrimaryColor="#0D7041"
                    SecondaryColor="#21A366" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

And my MainWindow.xaml

<Window
    x:Class="TEST.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:TEST"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="900"
    Height="600"
    Background="{DynamicResource BrushWhite}"
    FontFamily="{DynamicResource MaterialDesignFont}"
    ResizeMode="NoResize"
    StateChanged="Window_StateChanged"
    TextElement.FontSize="14"
    TextElement.FontWeight="Regular"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    TextOptions.TextFormattingMode="Ideal"
    TextOptions.TextRenderingMode="Auto"
    UseLayoutRounding="True"
    WindowStartupLocation="CenterScreen"
    WindowStyle="SingleBorderWindow"
    mc:Ignorable="d">
    ....
</Window>

I'm expecting a white background for this context menu as a default configuration.

CodePudding user response:

This is a bug in version 4.4.0, see here, here, and here.

Install the Version 4.5.0 instead, the issue has been fixed.

Install-Package MaterialDesignThemes -Version 4.5.0-ci133
  • Related