Fix exception thrown when changing themes when application uses relative and absolute URIs #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.
This PR adds a check for this to prevent an exception. My code no longer throws an exception and everything works as it should.