MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

Design time view is not the same as runtime

Open mouawadma opened this issue 2 years ago • 2 comments

Bug explanation

Hello, see the attached screenshot. Essentially, I set up this fresh project exactly as the get started instructions state (except for switching the basetheme from light to dark in app.xaml) and there is a discrepancy in how it is displayed when moving from design view to runtime view. Is there a way to fix this?

image


App.xaml

<Application x:Class="MDIXtest.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:MDIXtest"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <materialDesign:BundledTheme BaseTheme="Dark"
                                             PrimaryColor="DeepPurple"
                                             SecondaryColor="Lime" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

MainWindow.Xaml

<Window x:Class="MDIXtest.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MDIXtest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        Background="{DynamicResource MaterialDesignPaper}"
        TextElement.FontWeight="Medium"
        TextElement.FontSize="14"
        FontFamily="{materialDesign:MaterialDesignFont}">
    <StackPanel>
        <GroupBox Style="{StaticResource MaterialDesignGroupBox}"
                  Header="test">
            <TextBlock Text="test" />
        </GroupBox>
    </StackPanel>
</Window>

Version

4.9.0

mouawadma avatar Jul 01 '23 15:07 mouawadma

Hi @mouawadma this is likely an issue with how the designed loads and parses the App.xaml resources and how those are loaded (dynamically at runtime after those properties are set rather than at design-time). For the 5.0.0 release we are doing a major update to the theming dictionaries and theming, and I will see if there are any options when we build these dictionaries to do them in a way that the designer will like (however I can't promise a fix as we are limited by what the designer will support).

Keboo avatar Aug 10 '23 17:08 Keboo

Hi @mouawadma after digging into this after the v5 release, I was hoping for you to re-test. The behavior that I see is that the design does follow the theme colors, but only when viewing the Window, user controls will not follow the theme colors. For these, you can always setup design time color using the d: prefix. Something like this: d:Foreground="Red"

Keboo avatar Jun 13 '24 05:06 Keboo

This issue is marked stale because it has been open 30 days with no activity. Remove stale label or update the issue, otherwise it will be closed in 14 days.

github-actions[bot] avatar Jul 14 '24 01:07 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Jul 29 '24 01:07 github-actions[bot]