Wpf app with Noesis theme looks different as in xamltoy
I created a dummy WPF application (.net framework 4.8 )
Nuget package was installed: Noesis.GUI.Extensions (3.0.30.13778)
Referenced the theme with the pack-uri
I use for testing the sample code of Xamltoy "Noesis Theme" sample:
The theme looks like it's only partially applied.
Focusing for example only in the resource Brush.Window.Background, on the editor preview, it shows like it will be a dark color, but if you select the static resource and go to its source it shows it should be a white SolidColorBrush.
The unexpected color showing into the xaml preview on the left looks like it is matching what is shown when you launch the application
Hardcoding the background to be white improves the situation a little but does not solve the issue at all, the colors do not match at all the equivalent Theme sample in xaml toy
What can i do to address this issue?
Note: LightBlue looks much better even without the background hack ( i guess the default theme of xamltoy is LightBlue). Maybe there is some specific issue with DarkBlue. But still, why does the DarkBlue theme, look off?
Nuget package was installed: Noesis.GUI.Extensions (3.0.30.13778)
Referenced the theme with the pack-uri
Code: Select all
<Application.Resources>
<ResourceDictionary Source="pack://application:,,,/Noesis.GUI.Extensions;component/Theme/NoesisTheme.DarkBlue.xaml" />
</Application.Resources>
The theme looks like it's only partially applied.
Focusing for example only in the resource Brush.Window.Background, on the editor preview, it shows like it will be a dark color, but if you select the static resource and go to its source it shows it should be a white SolidColorBrush.
The unexpected color showing into the xaml preview on the left looks like it is matching what is shown when you launch the application
Hardcoding the background to be white improves the situation a little but does not solve the issue at all, the colors do not match at all the equivalent Theme sample in xaml toy
What can i do to address this issue?
Note: LightBlue looks much better even without the background hack ( i guess the default theme of xamltoy is LightBlue). Maybe there is some specific issue with DarkBlue. But still, why does the DarkBlue theme, look off?
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: Wpf app with Noesis theme looks different as in xamltoy
Hi,
Using a Grid as root means that the default value of the Foreground property (Black) is used for TextBlocks, as that property is not inherited from any Control. And because XamlToy uses NoesisTheme.LightBlue.xaml as the theme for the application resources, the black texts look quite good.
If you change your root to something like a Page, then the control style will set the appropriate Foreground depending on the Dark/Light theme.
Hope this clarifies things a bit.
Using a Grid as root means that the default value of the Foreground property (Black) is used for TextBlocks, as that property is not inherited from any Control. And because XamlToy uses NoesisTheme.LightBlue.xaml as the theme for the application resources, the black texts look quite good.
If you change your root to something like a Page, then the control style will set the appropriate Foreground depending on the Dark/Light theme.
In the dark themes, the brushes use the Colors.Dark.xaml that just have the same names but inverted (so Color.White is the darkest one in this case). That way both Dark and Light brushes xaml are exactly the same, just changing the reference to the Colors xaml, so nothing wrong here.Focusing for example only in the resource Brush.Window.Background, on the editor preview, it shows like it will be a dark color, but if you select the static resource and go to its source it shows it should be a white SolidColorBrush.
Hope this clarifies things a bit.
Re: Wpf app with Noesis theme looks different as in xamltoy
I have misdirected the explanation by providing that xamltoy
The host of the window in the Noesis Win32 application with the SDK is indeed a window
I've broken my local sdk setup but ill double check with the sdk on win32 and wasm
The host of the window in the Noesis Win32 application with the SDK is indeed a window
I've broken my local sdk setup but ill double check with the sdk on win32 and wasm
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: Wpf app with Noesis theme looks different as in xamltoy
I understand now, the problem is that the root element is a custom control and implicit styles only apply when the type matches exactly the same type. So in this case, as there is no Style defined for "workspace_hello.MainWindow" it won't apply any style from the theme. There are two options:
- Define a style for the custom type:
- The same way you are setting the Background on the root grid, you can set the Foreground for the window:
- Define a style for the custom type:
Code: Select all
<Style TargetType="{x:Type local:MainWindow}" BasedOn="{StaticResource {x:Type ContentControl}}"/>
Code: Select all
<Window x:Class="workspace_hello.MainWindow" ...
Foreground="{StaticResource Brush.Foreground.Normal}">
<Grid Background="{StaticResource Brush.Window.Background}".../>
</Window>
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 14 guests