Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms Resource file is not found

I did everything exactly as in this simple guide of how to access strings from another file anywhere in the Xamarin.forms project (in xaml and c#).

(https://learn.microsoft.com/de-de/xamarin/xamarin-forms/app-fundamentals/localization/text?pivots=windows)

However, it will simply not found my resouces, even If I set the build options to embedded resource.

THIS DOESNT WORK:

            <Label
                Grid.Row="1"
                Grid.Column="1"
                FontFamily="arial"
                FontSize="12"
                TextColor="#272727"
                Text="{x:Static local:AppResources.BgColor}" 
                HorizontalOptions="Start" 
                VerticalOptions="Start"/>

Screenshot of resx file and browser

It should work accordning to the manual but im getting: "Type AppResources not found in xmlns dr-namespace:app4.Renderer.

Please help me out here. Otherwise I have so many hardcoded strings in code and xaml files...

Thank you!

like image 897
user13397492 Avatar asked Feb 12 '26 21:02

user13397492


1 Answers

In the XAML file, add:

xmlns:resources="clr-namespace:MyApp.Resx"

MyApp = namespace; Resx = folder where the resource file is

like image 184
Ernesto Penalva Avatar answered Feb 15 '26 10:02

Ernesto Penalva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!