2016-10-13 5 views
6

C#/Xamarin에서 하이브리드 응용 프로그램을 만들고 모든 응용 프로그램 (iOS, Android, Windows Phone)에 대한 사용자 지정 메뉴를 만들고 싶습니다.Xamarin에서 글꼴/색상/크기를 변경하는 방법 C#

그래서 내 메뉴가 MasterPage입니다.

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 
      } 
    }; 
} 

MenuItem입니다 :

public class MenuItem 
{ 
    public string Title { get; set; } 

    public string IconSource { get; set; } 

    public Type TargetType { get; set; } 
    public string Parameter { get; set; } 
} 

그래서 지금은 C#으로 콘텐츠 페이지, 글꼴, 글꼴 색상, 글꼴 크기의 크기를 변경하고 싶습니다. 어떻게해야합니까?

답변

1

자 마린은 글꼴에 문서 양식 : 글꼴 : https://developer.xamarin.com/guides/xamarin-forms/user-interface/text/fonts/

예 :

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

내가주의 않는 당신은 글꼴의 속성이없는 ImageCell로하지만, 단지 텍스트 색상 및 DetailColor를 사용하는 재산. 또한 ImageCell에 기본 레이블을 가져 오는 속성이 없으므로 완전한 사용자 정의를 원한다면 자신의 ViewCell을 만들고 ViewCell에 이미지와 레이블을 추가하는 것이 가장 좋습니다. 그런 다음 글꼴 속성으로 레이블의 스타일을 지정할 수 있습니다. https://developer.xamarin.com/guides/xamarin-forms/themes/

StyleClass StyleClass 속성은 뷰의 모양은 테마에 의해 제공되는 정의에 따라 변경 될 수 있습니다 :

다른 방법으로, 당신은 미리보기에 테마를 사용할 수 있습니다.

관련 문제