benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.73k stars 145 forks source link

AdonisUI-Demo main Window falls back to default WPF not inheriting Adonis Windows Style. #27

Closed sodalom closed 5 years ago

sodalom commented 5 years ago

Describe the bug The code compiles and when AdonisUI.Demo is run the main windows doesn't inherit from Adonis and falls back to default WPF Window. Editing the MainWindow.xaml throws Severity Code Description Project File Line Suppression State Error 'SpaceExtension' is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types.

AdonisUI.Demo MainWindow.xaml

To Reproduce Steps to reproduce the behavior:

  1. Clone Repository
  2. Build run
  3. Edit MainWindow.xaml
  4. See error

Expected behavior MainWindow inherits the Adonis-UI theme.

Screenshot image

Additional context dotnet --version 2.2.203 Windows 7 x64

benruehl commented 5 years ago

I am not sure if I understand you correctly. To me this looks like an issue with the XAML Designer but you said it happens "when AdonisUI.Demo is run". Could you please clarify if the error occurs in the Visual Studio Designer or at runtime in the application?

Regarding the error you received: Using the designer I can reproduce the error in some situations. It occurs because the designer cannot handle the usage of MarkupExtensions in style setters. It works for some hard-coded types like Binding and DynamicResource but custom extensions like the SpaceExtension do always raise this error. As this is not the first case where the designer has problems dealing with the SpaceExtension, I will try to find an alternative that does not rely on custom MarkupExtensions.

Regarding the styles not being applied in the designer: Besides the error, the designer seems to fail to load resources that reside in App.xaml. This is not an issue with the library though. If you want the designer to make use of the styles you can include them explicitly in the window's resources in addition to the app's resources. For me, the designer is able to find the resources in that case. This might have performance implications though as the ResourceDictionaries are instantiated multiple times in that case. So my advice would be to just accept that some styles might not be applied in the designer as it is not a perfect copy of the application anyways.

sodalom commented 5 years ago

The error only occurs in XAML Designer. The app works in run time except not inheriting the Window style. But now your comments clarified to me where I went wrong. I close the issue now.