Kinnara / ModernWpf

Modern styles and controls for your WPF applications
MIT License
4.51k stars 450 forks source link

High Contrast resource dictionary reference in ModernWpf.SampleApp throws System.Windows.Markup.XamlParseException #659

Open dostjh opened 11 months ago

dostjh commented 11 months ago

DESCRIPTION I tried to clone the ModernWpf repository and compile and run the ModernWpf.SampleApp with no changes since I wanted to browse the controls and their functionality. The build compiles fine. But I hit an exception on application execution before startup completes.


Inner Exception
Exception: Cannot find resource named 'SystemColorButtonTextColorBrush'. Resource names are case sensitive.

This occurs on several brushes.

Eventually, I resorted to commenting out the reference to the HighContrast resource dictionary in ModernWpf\ModernWpf.SampleApp\App.xaml line 37 through 41 to get the application to run.

I am cloned to commit 218e8ec100caf4f653835d207977e631b869f7a4. I am running Windows 11.

Call Stack:

    PresentationFramework.dll!System.Windows.Markup.XamlReader.RewrapException(System.Exception e, System.Xaml.IXamlLineInfo lineInfo, System.Uri baseUri) Line 362 C#
    PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri) Line 121  C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.CreateObject(System.Windows.Baml2006.KeyRecord key) Line 1176   C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValue(object key, ref object value, out bool canCache) Line 985    C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValuePrivate(object key, ref object value, out bool canCache) Line 950 C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.GetValueWithoutLock(object key, out bool canCache) Line 684 C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.GetValue(object key, out bool canCache) Line 676    C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.ResourceDictionaryEnumerator.System.Collections.IDictionaryEnumerator.Entry.get() Line 42   C#
    PresentationFramework.dll!System.Windows.ResourceDictionary.ResourceDictionaryEnumerator.System.Collections.IEnumerator.Current.get()   C#
    ModernWpf.dll!ModernWpf.ColorsHelper.UpdateBrushes(System.Windows.ResourceDictionary themeDictionary, System.Windows.ResourceDictionary colors) Line 101    C#
    ModernWpf.dll!ModernWpf.ColorsHelper.UpdateBrushes(System.Windows.ResourceDictionary themeDictionary) Line 96   C#
    ModernWpf.dll!ModernWpf.ThemeManager.ApplyAccentColor() Line 198    C#
    ModernWpf.dll!ModernWpf.ThemeManager.Initialize() Line 797  C#
    ModernWpf.dll!ModernWpf.ThemeResources.EndInit() Line 214   C#
    ModernWpf.dll!ModernWpf.ThemeResources.System.ComponentModel.ISupportInitialize.EndInit() Line 238  C#
    System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(System.Xaml.XamlType xamlType, object obj, bool begin)    Unknown
    System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_EndInit(MS.Internal.Xaml.Context.ObjectWriterContext ctx)    Unknown
    System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndObject()   Unknown
    PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, System.Xaml.IXamlLineInfo xamlLineInfo, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack, System.Windows.Markup.IStyleConnector styleConnector) Line 167 C#
    PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri) Line 111  C#
    PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader xamlReader, bool skipJournaledProperties, object rootObject, System.Xaml.Permissions.XamlAccessLevel accessLevel, System.Uri baseUri) Line 38 C#
    PresentationFramework.dll!System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, object parent, bool closeStream) Line 764   C#
    ModernWpf.SampleApp.exe!ModernWpf.SampleApp.App.InitializeComponent() Line 1    C#
    ModernWpf.SampleApp.exe!ModernWpf.SampleApp.App.Main()  Unknown

Note, I am running on Windows 11, so maybe high contrast is differently set up.