You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception on Android and WASM after adding a style to a menuflyoutitem #3216
area/code-generationCategorizes an issue or PR as relevant to code generationkind/bugSomething isn't workingproject/styling 👔Categorizes an issue or PR as relevant to element styling
System.Exception
Message=Failed to load UnoFlyoutStyleIssue.MainPage: System.InvalidOperationException: The resource menuFlyoutItemStyle cannot be found
at UnoFlyoutStyleIssue.MainPage+<>c__DisplayClass2_0.b__1 (UnoFlyoutStyleIssue.MainPage c3) [0x00001] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_523c63a278830d164cac6f1cfbdba873.g.cs:87
at Uno.Extensions.ObjectExtensions.Apply[TSource] (TSource source, System.Action`1[T] action) [0x00000] in D:\a\1\s\src\Uno.Core\Extensions\ObjectExtensions.cs:110
at UnoFlyoutStyleIssue.MainPage.InitializeComponent () [0x000bc] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_523c63a278830d164cac6f1cfbdba873.g.cs:81
at UnoFlyoutStyleIssue.MainPage..ctor () [0x00013] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Shared\MainPage.xaml.cs:27
at UnoFlyoutStyleIssue.Droid.MetadataBuilder_643.CreateInstance () [0x00000] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\BindableTypeProvidersSourceGenerator\BindableMetadata.g.cs:31058
at Windows.UI.Xaml.Controls.Frame.CreatePageInstance (System.Type sourcePageType) [0x00016] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:414
at Windows.UI.Xaml.PagePool.DequeuePage (System.Type pageType) [0x00007] in d:\a\1\s\src\Uno.UI\UI\Xaml\PagePool.cs:69
at Windows.UI.Xaml.Controls.Frame.CreatePageInstanceCached (System.Type sourcePageType) [0x00000] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:404
at Windows.UI.Xaml.Controls.Frame.InnerNavigate (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x0009b] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:311
Indeed, there's a special case for this, where you defined your style using x:Name instead of x:Key. This may be something that will be addressed by #1766.
System.Exception: 'Failed to load Frebo.Biblioteko.Mobile.MainView.HomePage: System.MissingMethodException: Method not found: Windows.UI.Xaml.Media.SolidColorBrush Uno.UI.GlobalStaticResources.get_ApplicationForegroundThemeBrush()
at Windows.UI.Xaml.Setter.ApplyTo (Windows.UI.Xaml.DependencyObject o) [0x00008] in D:\a\1\s\src\Uno.UI\UI\Xaml\Setter.cs:76
at Windows.UI.Xaml.Style.ApplyTo (Windows.UI.Xaml.DependencyObject o, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence) [0x0003f] in D:\a\1\s\src\Uno.UI\UI\Xaml\Style\Style.cs:68
at Windows.UI.Xaml.FrameworkElement.OnStyleChanged (Windows.UI.Xaml.Style oldStyle, Windows.UI.Xaml.Style newStyle, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence) [0x00011] in D:\a\1\s\src\Uno.UI\UI\Xaml\FrameworkElement.cs:374
at Windows.UI.Xaml.FrameworkElement.ApplyDefaultStyle () [0x0001c] in D:\a\1\s\src\Uno.UI\UI\Xaml\FrameworkElement.cs:392
at Windows.UI.Xaml.FrameworkElement.ApplyStyles () [0x00006] in D:\a\1\s\src\Uno.UI\UI\Xaml\FrameworkElement.cs:275
at Windows.UI.Xaml.FrameworkElement.CreationComplete () [0x00014] in D:\a\1\s\src\Uno.UI\UI\Xaml\FrameworkElement.cs:293
at Frebo.Biblioteko.Mobile.MainView.HomePage+<>c.<InitializeComponent>b__1_23 (Microsoft.Toolkit.Uwp.UI.Controls.ImageEx c11) [0x0000d] in C:\Users\Andrii\Dev\Frebo\Biblioteko\Biblioteko.Mobile.Android\obj\Debug\90\g\XamlCodeGenerator\HomePage_a1c3e85ce99589774302cf397f8d10aa.g.cs:479
at Frebo.Biblioteko.Mobile.HomePage_a1c3e85ce99589774302cf397f8d10aaXamlApplyExtensions.HomePage_a1c3e85ce99589774302cf397f8d10aa_XamlApply (Microsoft.Toolkit.Uwp.UI.Controls.ImageEx instance, Frebo.Biblioteko.Mobile.HomePage_a1c3e85ce99589774302cf397f8d10aaXamlApplyExtensions+XamlApplyHandler9 handler) [0x00001] in C:\Users\Andrii\Dev\Frebo\Biblioteko\Biblioteko.Mobile.Android\obj\Debug\90\g\XamlCodeGenerator\HomePage_a1c3e85ce99589774302cf397f8d10aa.g.cs:1146
at Frebo.Biblioteko.Mobile.MainView.HomePage.InitializeComponent () [0x00137] in C:\Users\Andrii\Dev\Frebo\Biblioteko\Biblioteko.Mobile.Android\obj\Debug\90\g\XamlCodeGenerator\HomePage_a1c3e85ce99589774302cf397f8d10aa.g.cs:164
at Frebo.Biblioteko.Mobile.MainView.HomePage..ctor () [0x00008] in C:\Users\Andrii\Dev\Frebo\Biblioteko\Biblioteko.Mobile.Shared\MainView\HomePage.xaml.cs:28
at Frebo.Biblioteko.Mobile.MetadataBuilder_766.CreateInstance () [0x00000] in C:\Users\Andrii\Dev\Frebo\Biblioteko\Biblioteko.Mobile.Android\obj\Debug\90\g\BindableTypeProvidersSourceGenerator\BindableMetadata.g.cs:36273
at Windows.UI.Xaml.Controls.Frame.CreatePageInstance (System.Type sourcePageType) [0x00016] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:416
at Windows.UI.Xaml.PagePool.DequeuePage (System.Type pageType) [0x00007] in D:\a\1\s\src\Uno.UI\UI\Xaml\PagePool.cs:69
at Windows.UI.Xaml.Controls.Frame.CreatePageInstanceCached (System.Type sourcePageType) [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:406
at Windows.UI.Xaml.Controls.Frame.InnerNavigate (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x0009b] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:313 '
area/code-generationCategorizes an issue or PR as relevant to code generationkind/bugSomething isn't workingproject/styling 👔Categorizes an issue or PR as relevant to element styling
Activity
BrianDT commentedon May 21, 2020
System.Exception
Message=Failed to load UnoFlyoutStyleIssue.MainPage: System.InvalidOperationException: The resource menuFlyoutItemStyle cannot be found
at UnoFlyoutStyleIssue.MainPage+<>c__DisplayClass2_0.b__1 (UnoFlyoutStyleIssue.MainPage c3) [0x00001] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_523c63a278830d164cac6f1cfbdba873.g.cs:87
at Uno.Extensions.ObjectExtensions.Apply[TSource] (TSource source, System.Action`1[T] action) [0x00000] in D:\a\1\s\src\Uno.Core\Extensions\ObjectExtensions.cs:110
at UnoFlyoutStyleIssue.MainPage.InitializeComponent () [0x000bc] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_523c63a278830d164cac6f1cfbdba873.g.cs:81
at UnoFlyoutStyleIssue.MainPage..ctor () [0x00013] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Shared\MainPage.xaml.cs:27
at UnoFlyoutStyleIssue.Droid.MetadataBuilder_643.CreateInstance () [0x00000] in D:\Development\GitHub\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue\UnoFlyoutStyleIssue.Droid\obj\Debug\90\g\BindableTypeProvidersSourceGenerator\BindableMetadata.g.cs:31058
at Windows.UI.Xaml.Controls.Frame.CreatePageInstance (System.Type sourcePageType) [0x00016] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:414
at Windows.UI.Xaml.PagePool.DequeuePage (System.Type pageType) [0x00007] in d:\a\1\s\src\Uno.UI\UI\Xaml\PagePool.cs:69
at Windows.UI.Xaml.Controls.Frame.CreatePageInstanceCached (System.Type sourcePageType) [0x00000] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:404
at Windows.UI.Xaml.Controls.Frame.InnerNavigate (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x0009b] in d:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:311
Xiaoy312 commentedon May 30, 2020
strangely the generated local resource (style) isnt being used anywhere:
private void InitializeComponent() { var nameScope = new global::Windows.UI.Xaml.NameScope(); NameScope.SetNameScope(this, nameScope); Content = new global::Windows.UI.Xaml.Controls.Grid { RowDefinitions = { ... }, Children = { new global::Windows.UI.Xaml.Controls.TextBlock { ... }.MainPage_dec80355600d10724bff248f43da21f1_XamlApply(...), new global::Windows.UI.Xaml.Controls.CommandBar { // Empty collection SecondaryCommands = { new global::Windows.UI.Xaml.Controls.AppBarButton { ..., Flyout = new global::Windows.UI.Xaml.Controls.MenuFlyout { // Source ..\..\..\..\..\..\..\UnoFlyoutStyleIssue.Shared\MainPage.xaml (Line 33:26) Items = { new global::Windows.UI.Xaml.Controls.MenuFlyoutItem { - Style = (Windows.UI.Xaml.Style)global::Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(Windows.UI.Xaml.Style), (global::Windows.UI.Xaml.Application.Current.Resources["menuFlyoutItemStyle"] ?? throw new InvalidOperationException("The resource menuFlyoutItemStyle cannot be found"))), ... }.MainPage_dec80355600d10724bff248f43da21f1_XamlApply(...), } }, // Source ..\..\..\..\..\..\..\UnoFlyoutStyleIssue.Shared\MainPage.xaml (Line 27:18) }.MainPage_dec80355600d10724bff248f43da21f1_XamlApply(...), }, // Source ..\..\..\..\..\..\..\UnoFlyoutStyleIssue.Shared\MainPage.xaml (Line 23:10) }.MainPage_dec80355600d10724bff248f43da21f1_XamlApply(...), } }.MainPage_dec80355600d10724bff248f43da21f1_XamlApply(...); this.Apply(...).Apply(...); OnInitializeCompleted(); InitializeXamlOwner(); // Source ..\..\..\..\..\..\..\UnoFlyoutStyleIssue.Shared\MainPage.xaml (Line 9:10) - new global::Windows.UI.Xaml.Style(typeof(global::Windows.UI.Xaml.Controls.MenuFlyoutItem)) - { - Setters = - { - new global::Windows.UI.Xaml.Setter(global::Windows.UI.Xaml.Controls.MenuFlyoutItem.BackgroundProperty, () => (Windows.UI.Xaml.Media.Brush)(Windows.UI.Xaml.Media.Brush)global::Uno.UI.GlobalStaticResources.ApplicationPageBackgroundThemeBrush), - new global::Windows.UI.Xaml.Setter(global::Windows.UI.Xaml.Controls.MenuFlyoutItem.ForegroundProperty, () => (Windows.UI.Xaml.Media.Brush)(Windows.UI.Xaml.Media.Brush)global::Uno.UI.GlobalStaticResources.ApplicationForegroundThemeBrush), - new global::Windows.UI.Xaml.Setter(global::Windows.UI.Xaml.Controls.MenuFlyoutItem.OpacityProperty, (double)1d/* double/double, 1, Setter/Value */), - } - }; }jeromelaban commentedon May 31, 2020
Thanks for the report!
Indeed, there's a special case for this, where you defined your style using
x:Nameinstead ofx:Key. This may be something that will be addressed by #1766./cc @davidjohnoliver
davidjohnoliver commentedon Jun 1, 2020
Yes, this should be fixed with #1766.
xperiandri commentedon Jun 14, 2020
Looks like it is related
xperiandri commentedon Jun 14, 2020
xperiandri commentedon Jun 14, 2020
Happen on Android for me
xperiandri commentedon Jun 14, 2020
Do I need to create a separate issue for this?
xperiandri commentedon Jun 14, 2020
Tried
<Border x:Key="*Work Around Border for ImageEx ApplicationForegroundThemeBrush Issue" Background="{ThemeResource ApplicationForegroundThemeBrush}" />Got
Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference'xperiandri commentedon Jun 14, 2020