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

"key not found" occurs when referring to resource dictionaries in other assembly #27023

Open
jevonsflash opened this issue Jan 9, 2025 · 3 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@jevonsflash
Copy link

Description

I have a program that uses two resource dictionaries from another library, Color.xaml and Style.xaml, where Style refers to the static resource in Color, and when I refer to them in the main program, I get an error:"Position 21:17. StaticResource not found for key Gray150"TestStyle.zip

Steps to Reproduce

  1. Create a MAUI library,
  2. Create two resource dictionary(colors, styles), and the second resource depends on the first, so it should be added to MergedDictionaries before initialization

        public TestStyleResources()
        {
            this.MergedDictionaries.Add(new TestStyleColors());

            InitializeComponent();         

        }
  1. In the second resource dictionary, introduce other dictionaries, such as "Styles/VCheckBox.xaml"

  2. Create a default MAUI project with the default template and reference to library

  3. Create these two resources in App.xaml

                <control:TestStyleColors></control:TestStyleColors>
                <control:TestStyleResources></control:TestStyleResources>
  1. Run the program and the error occurs at InitializeComponent()

Tested write the style directly in the style dictionary is ok:

 <ResourceDictionary.MergedDictionaries>


     <!--This is not ok-->

     <ResourceDictionary Source="Styles/VCheckBox.xaml" />





     <!--This is ok-->

     <!--<ResourceDictionary>
         <Style x:Key="CheckBoxSelBorder"
                TargetType="Border">
             <Setter Property="StrokeShape"
                     Value="RoundRectangle 14" />
             <Setter Property="HeightRequest"
                     Value="28" />
             <Setter Property="WidthRequest"
                     Value="28" />
             <Setter Property="HorizontalOptions"
                     Value="Center" />
             <Setter Property="VerticalOptions"
                     Value="Center" />
             <Setter Property="Stroke"
                     Value="{StaticResource Gray150}" />
             <Setter Property="StrokeThickness"
                     Value="0" />
             <Setter Property="BackgroundColor"
                     Value="{StaticResource Success}" />
         </Style>
        
....
     </ResourceDictionary>-->
     
     
     
 </ResourceDictionary.MergedDictionaries>

Link to public reproduction project repository

No response

Version with bug

8.0.100 SR10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

@jevonsflash jevonsflash added the t/bug Something isn't working label Jan 9, 2025
@jevonsflash
Copy link
Author

There may be the same problems associated:
#8799 (comment)

@jfversluis jfversluis added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jan 9, 2025
Copy link
Contributor

Hi @jevonsflash. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jfversluis
Copy link
Member

Please try the latest version on .NET 9 and let us know if it still reproduces then

@jfversluis jfversluis added the area-xaml XAML, CSS, Triggers, Behaviors label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants