Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms Font is obsolete

When I am trying to create anew label on Xamarin.Forms, I get the following Warning:

about = new Label { Text = "" ,      
                TextColor=Color.Black,
                Font = Font.SystemFontOfSize(16),//Warning occurred here 
                XAlign = TextAlignment.End,
                HorizontalOptions = LayoutOptions.EndAndExpand};

'Xamarin.Forms.Label.Font' is obsolete: 'Please use the Font attributes which are on the class itself. Obsoleted in v1.3.0'

What this warning means and what I should do?

like image 377
Mohamad Mahmoud Avatar asked Mar 12 '23 22:03

Mohamad Mahmoud


2 Answers

Use the FontSize, FontFamily, and FontAttributes properties of the Label class instead.

https://developer.xamarin.com/guides/xamarin-forms/user-interface/text/fonts/

like image 124
Keith Rome Avatar answered Mar 23 '23 07:03

Keith Rome


You should just listen to the warning and change it to FontSize. In next releases of Xamarin.Forms this property can be removed and your code no longer will compile.

Marking some method/property as obsolete is very often used by maintainers of libraries to warn users that this particular member can be removed in next releases of library.

like image 43
Arkadiusz K Avatar answered Mar 23 '23 08:03

Arkadiusz K