wpfui
wpfui copied to clipboard
Visual studio's Editor not showing controls correctly when using the WPF UI library in an existing project
Describe the bug
After downloading the NuGet package into an existing WPF project, Visual Studio's built-in Editor only seems to show ui:Buttons with the "Appearance" property set to "Primary". All other controls are invisible (see screenshot).
Here's my App.xaml file:
<Application x:Class="Kviz.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Kviz"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
StartupUri="Form1.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
To Reproduce
- Create a new standard WPF project.
- Add the WPF-UI NuGet package to it.
- Add controls to a page or window.
- Observe the issue.
Expected behavior
The editor should either:
- Show dark mode and all controls white, or
- Show normal light mode and all controls black.
Screenshots
OS version
Windows 11 Pro 22H2 (Build 22621.1992) - AMD64
.NET version
.NET 7.0.306
WPF-UI NuGet version
WPF UI 2.0.3
Additional context
Visual Studio 2022 version: 17.6.5
i have the same issue, the designer is still showing plain WPF elements
Edit: I was using VS2019, and this was resolved after updating to VS2022
For me the designer is showing no elements at all unless I set the appearance property to Primary, and that is only possible on some elements
Hey there @yesseruser, did you ever manage to resolve that problem? I'm facing the same issue...
This occurs because you are using Dark controls on the light background in preview.
To allow displaying proper preview on a black background, add a Background or ui:Design.Background to your control.
https://github.com/lepoco/wpfui/blob/7fcc2d8410f056d1d6de97c2f8078b3d8b38539b/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml#L19C5-L19C5
Thanks a lot @pomianowski, that makes embarrassingly much sense... and sure enough, that fixed it.
https://github.com/lepoco/wpfui/blob/7fcc2d8410f056d1d6de97c2f8078b3d8b38539b/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml#L19C5-L19C5
https://github.com/lepoco/wpfui/blob/7fcc2d8410f056d1d6de97c2f8078b3d8b38539b/src%2FWpf.Ui.Gallery%2FViews%2FWindows%2FMainWindow.xaml#L19
( ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
)
Does {DynamicResource ApplicationBackgroundBrush}
auto update based on user's color scheme?
@robng Please close this issue.