简体   繁体   中英

C# resource file - how to access internal resources from XAML?

This is my simple (newbie) understanding:
We have a choice for the Ressource Code Generator: internal or public . The default appears to be internal . I understand the resources are created with an internal or public accessor depending on that choice. Therefore, if the accessor is public I can use something like: Text="{x:Static resx:Resources.SomeLabelID}" ... in my XAML.
My question is either/both:

  • What use is a generated internal accessor when the XAML shown above does not work (more precisely it 'works' in design mode but not at run time thus creating confusion for a newbie)? Note: There are many answers in SO that simply say to change the accessor to 'public' without explaining why, which I think would by nice to understand, especially since the default appears to be internal.

-OR-

  • Is there another way to access resource strings (from XAML) when the code is generated with the internal accessor ?

Thank you

Everything defined in XAML is using internal access modifier. That is by design of WPF framework, simply so you will not be able to access locally defined controls in different assembly.

Generally if you are going to use strings for "static" controls (ie Label ) then you can simply go a head with changing access modifier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM