Ped*_*nco 6 c# android ios windows-phone xamarin
我在C#/ Xamarin中制作混合应用程序,我想为所有应用程序(iOS,Android,Windows Phone)制作自定义菜单.
所以,我创建了一个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
}
};
}
Run Code Online (Sandbox Code Playgroud)
这是MenuItem:
public class MenuItem
{
public string Title { get; set; }
public string IconSource { get; set; }
public Type TargetType { get; set; }
public string Parameter { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
所以现在我想在C#中更改内容页面,字体,字体颜色,字体大小的大小.我该怎么办?
关于字体的 Xamarin Forms 文档:字体: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"
};
Run Code Online (Sandbox Code Playgroud)
我确实注意到您使用的是 ImageCell,它没有 Font 属性,只有 TextColor 和 DetailColor 属性。此外,没有属性可以获取 ImageCell 中的基础标签,因此如果您想要完全自定义,最好的选择是创建自己的 ViewCell 并将图像和标签添加到 ViewCell。然后您可以使用字体属性设置标签的样式。
或者,您可以使用预览版中的主题:https://developer.xamarin.com/guides/xamarin-forms/themes/
StyleClass StyleClass 属性允许根据主题提供的定义来更改视图的外观。
| 归档时间: |
|
| 查看次数: |
2047 次 |
| 最近记录: |