Skip to content

Fix exception thrown when changing themes when application uses relative and absolute URIs#40

Merged
benruehl merged 1 commit intobenruehl:masterfrom
Mgamerz:patch-1
Nov 27, 2019
Merged

Fix exception thrown when changing themes when application uses relative and absolute URIs#40
benruehl merged 1 commit intobenruehl:masterfrom
Mgamerz:patch-1

Conversation

@Mgamerz
Copy link
Copy Markdown
Contributor

@Mgamerz Mgamerz commented Nov 26, 2019

I am using a slightly modified version of this library in my source code (as a source project), however I have not modified any of the loading code.

In my app's App.xaml I add a merged dictionary with some styles and converters I like to use all over:

image

I use relative paths, because it seems simpler to me to do it this way rather than the rather complicated absolute uri path.

When I call SetColorTheme(), the application crashes when it's trying to enumerate the resource dictionaries.
ResourceLocator.SetColorScheme(Application.Current.Resources, Settings.DarkTheme ? ResourceLocator.DarkColorScheme : ResourceLocator.LightColorScheme);

Looking at the exception and the code involved, it is because it does not check if it is an absolute or relative URI before it tries to resolve an absolute URI.

image

This PR adds a check for this to prevent an exception. My code no longer throws an exception and everything works as it should.

@benruehl
Copy link
Copy Markdown
Owner

Looks good and makes totally sense.
Thanks a lot :)

@benruehl benruehl merged commit c971fbc into benruehl:master Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants