Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 27, 2019

Conversation

Mgamerz
Copy link
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
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