benruehl / adonis-ui

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

Error Dimensions.HorizontalSpace resource with new MainWindow() #149

Open fikrivoxel opened 3 years ago

fikrivoxel commented 3 years ago

Describe the bug i got error

 System.Windows.ResourceReferenceKeyNotFoundException: Cannot find Dimensions.HorizontalSpace resource

with new MainWindow() show in App OnStartup

To Reproduce Steps to reproduce the behavior:

  1. Use MainWindow

    Margin="{adonisUi:Space 1}

    in MainWindow xaml

  2. Code OnStartup

    private void App_OnStartup(object sender, StartupEventArgs e)
    {
    MainWindow.Show();
    }
  3. Running get error message

    
    System.Windows.ResourceReferenceKeyNotFoundException: Cannot find Dimensions.HorizontalSpace resource.
    at AdonisUI.SpaceExtension.FindAndCacheSpaceResources(IProvideValueTarget service)
    at AdonisUI.SpaceExtension.GetHorizontalSpace(IProvideValueTarget service)
    at AdonisUI.SpaceExtension.ProvideValue(IServiceProvider serviceProvider)
    at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
    --- End of inner exception stack trace ---
    at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObjec
    t, XamlObjectWriterSettings settings, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri
    baseUri)
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
    at KosApp.MainWindow.InitializeComponent() in E:\Projects\KosApp\KosApp\MainWindow.xaml:line 1
    at KosApp.MainWindow..ctor() in E:\Projects\KosApp\KosApp\MainWindow.xaml.cs:line 13
    at KosApp.App..ctor() in E:\Projects\KosApp\KosApp\App.xaml.cs:line 22
    at KosApp.App.Main()


**Expected behavior**
im expect can use space 

**Screenshots**
![Capture](https://user-images.githubusercontent.com/54853868/108085039-7897dd80-70a7-11eb-99a0-d1dd571bc034.PNG)
![Capture2](https://user-images.githubusercontent.com/54853868/108085172-a1b86e00-70a7-11eb-97e1-f7751a46217f.PNG)
![Capture3](https://user-images.githubusercontent.com/54853868/108085176-a3823180-70a7-11eb-8a15-2080467afe40.PNG)
benruehl commented 3 years ago

This should definitely work. Did you add Adonis UI to your App.xaml correctly like this?

<Application xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI;component/ColorSchemes/Light.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI.ClassicTheme;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>