adonis-ui icon indicating copy to clipboard operation
adonis-ui copied to clipboard

Error Dimensions.HorizontalSpace resource with new MainWindow()

Open fikrivoxel opened this issue 3 years ago • 1 comments

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

  1. Code OnStartup
private void App_OnStartup(object sender, StartupEventArgs e)
{
   MainWindow.Show();
}
  1. 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 Capture2 Capture3

fikrivoxel avatar Feb 16 '21 15:02 fikrivoxel

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>

benruehl avatar Mar 14 '21 00:03 benruehl