unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.09k stars 739 forks source link

Referencing `ResourceDictionary` from a non-Application element does not work #5059

Open LeftTwixWand opened 3 years ago

LeftTwixWand commented 3 years ago

Current behavior

If I'll try to reference resource dictionary from NavigationView.Resources - it's not working

<NavigationView RequestedTheme="Light">
    <NavigationView.Resources>
        <ResourceDictionary Source="Themes/PurpleTheme.xaml"/>
    </NavigationView.Resources>
</NavigationView>

Strange, because It works as minimum 1 time at start - from App.xaml

How to reproduce it (as minimally and precisely as possible)

git clone https://github.com/LeftTwixWand/UnoApp.git git checkout cb210e6cadabb084a065bee2b90cb0d6d45d336b

Environment

Nuget Package:

Nuget Package Version(s): 3.5.0-dev.212

Affected platform(s):

IDE:

Relevant plugins:

MartinZikmund commented 3 years ago

RequestedTheme is not yet fully supported, only Application-level theme. We are tracking this at #3302. Please up-vote that issue so we can prioritize it 🙂

MartinZikmund commented 3 years ago

Regarding the second issue - does referencing the ResourceDictionary this way work in UWP? And can you try if /Themes/PurpleTheme.xaml would work (with the leading /)?

davidjohnoliver commented 3 years ago

RequestedTheme is not yet fully supported, only Application-level theme. We are tracking this at #3302. Please up-vote that issue so we can prioritize it 🙂

To expand on this slightly - FrameworkElement.RequestedTheme is currently supported in Uno in one case, for the root view in the window: https://platform.uno/docs/articles/api-differences.html#themes

This is to support the use case of switching the whole application's theme programmatically from the app at runtime.

Uno.UI and UWP API or Behavior differences
LeftTwixWand commented 3 years ago

Regarding the second issue - does referencing the ResourceDictionary this way work in UWP? And can you try if /Themes/PurpleTheme.xaml would work (with the leading /)?

Yes, it works in UWP.

In one week I'll have a free time and I want to start Uno contributing. How can I help you, guys?

jeromelaban commented 3 years ago

This feature is pretty deep, but @MartinZikmund tried implementing this in https://github.com/unoplatform/uno/pull/3387. I don't recall what was missing in that PR.

MartinZikmund commented 3 years ago

Changed this issue to track the second problem only, for RequestedTheme please see #3302