How to change font / color / size in Xamarin C #

I am making a hybrid application in C # / Xamarin and I want to create my own menu for all applications (iOS, Android, Windows Phone).

So, I create MasterPage as my menu.

 public MasterPage() { InitializeComponent(); var masterPageItems = new List<MenuItem>(); masterPageItems.Add(new MenuItem { Title = "Administraรงรฃo", }); masterPageItems.Add(new MenuItem { Title = "Meus Dados", IconSource = "contacts.png", TargetType = typeof(MeusDados), }); masterPageItems.Add(new MenuItem { Title = "Dados Cadastrais", IconSource = "contacts.png", TargetType = typeof(MeusNegocios), }); var listView = new ListView { ItemsSource = masterPageItems, ItemTemplate = new DataTemplate(() => { var imageCell = new ImageCell(); imageCell.SetBinding(TextCell.TextProperty, "Title"); imageCell.SetBinding(ImageCell.ImageSourceProperty, "IconSource"); return imageCell; }), VerticalOptions = LayoutOptions.FillAndExpand, SeparatorVisibility = SeparatorVisibility.None }; Padding = new Thickness(0, 20, 0, 0); Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, Children = { listView } }; } 

This is MenuItem :

 public class MenuItem { public string Title { get; set; } public string IconSource { get; set; } public Type TargetType { get; set; } public string Parameter { get; set; } } 

So now I want to change the page size of the content, font, font color, font size in C #. How should I do it?

+6
source share
1 answer

Xamarin Forms Document for Fonts: Fonts: https://developer.xamarin.com/guides/xamarin-forms/user-interface/text/fonts/

Example:

 var about = new Label { FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, Text = "Medium Bold Font" }; 

I note that you are using ImageCell, which has no Font properties, but only the TextColor and DetailColor property. There are also no properties for getting basic shortcuts in ImageCell, so the best thing if you want to fully customize is to create your own ViewCell and add the image and shortcuts to ViewCell. You can then style your shortcuts with the Font properties.

Alternatively, you can use Themes found in Preview: https://developer.xamarin.com/guides/xamarin-forms/themes/

StyleClass The StyleClass property allows you to change the appearance of the view in accordance with the definition provided by the theme.

+1
source

All Articles